Yealink T48G의 전화 번호부로 사용하기 위해 ADLDS ldap에 연락처를 쓰려고합니다. 때때로 연락처의 이름에는 "ö", "ß"및 "é"와 같은 특수 문자가 포함됩니다. 이러한 문자가 "givenName"또는 "displayName"필드에 포함되어 있으면 전화 나 LDAP 클라이언트 모두 올바르게 표시 할 수없고 대신 다른 문자 (예 : "ö"-> "¶")를 표시 할 수 있지만 "이름 "및"dn "필드는이 문자를 올바르게 표시합니다.C# : ADLDS에 특수 문자를 쓰는 방법은 무엇입니까?
ADSI 편집 또는 다른 도구를 통해 연락처 값을 삽입하면 전화기에 이름이 올바르게 표시되지만 내 응용 프로그램은 givenName에서 삽입 한 특수 문자를 더 이상 읽을 수 없으며 일부 질문 표시 상자를 표시하지만 dn 및 이름 필드가 올바르게 읽혀집니다.
저는 이미 응용 프로그램의 인코딩으로 utf-8, utf-16, utf-32, iso-8859-1 및 windows-1252를 사용해 보았습니다.
그래서 질문은 ADLDS 인스턴스의 inetOrgPerson에 대한 givenName 속성에 C#을 사용하여 이러한 특수 문자를 저장할 수 있습니까?
올바르게 표시 :
잘못 표시 :
내 코드 : 문제는 사용되어야 protocolversion을 설정하여 해결되었습니다
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices.Protocols;
using System.Net;
namespace LdapContacts
{
public class LdapClient
{
private LdapConnection connection;
public LdapClient(string host, int port, string distinguishedUsername, string password)
{
connection = new LdapConnection(new LdapDirectoryIdentifier(host, port));
connection.AuthType = AuthType.Basic;
connection.Credential = new NetworkCredential(distinguishedUsername, password);
connection.Bind();
}
public AddResponse SendAddRequest(string distinguishedName, List<DirectoryAttribute> attributes)
{
AddRequest request = new AddRequest(distinguishedName, attributes.ToArray());
return connection.SendRequest(request) as AddResponse;
}
public SearchResponse SendSearchRequest(string distinguishedName, string filter)
{
SearchRequest request = new SearchRequest();
request.DistinguishedName = distinguishedName;
request.Filter = filter;
request.Scope = SearchScope.Subtree;
return connection.SendRequest(request) as SearchResponse;
}
}
public class ContactsToLdap
{
private static void Main(string[] args)
{
LdapClient client = new LdapClient(Settings.LdapHost, Settings.LdapPort, Settings.LdapUsername, Settings.LdapPassword);
client.SendAddRequest("CN=Testöäüß,CN=Users,CN=testpart,DC=csdomain,DC=local", new List<DirectoryAttribute>()
{
new DirectoryAttribute("telephoneNumber", ""),
new DirectoryAttribute("objectClass", "inetOrgPerson"),
new DirectoryAttribute("uid", "io3e"),
new DirectoryAttribute("givenName", "â é testnameöüÄß")
});
//distinguished name of contactsfolder
SearchResponse result = client.SendSearchRequest(Settings.LdapContactsFolder, "(objectClass=inetOrgPerson)");
foreach (SearchResultEntry sResult in result.Entries)
{
//display the index of the current entry
Console.Write((result.Entries.IndexOf(sResult) + 1) + ":\n");
foreach (DirectoryAttribute attribute in sResult.Attributes.Values)
{
//output the name of the attribute
Console.Write("\t" + attribute.Name + " = ");
for (int i = 0; i < attribute.Count; i++)
{
// convert the attribute to a string if it is an byte[]
// output if inserted with ADSI-Edit: ? ? testname????
// output if inserted with this code: â é testnameöüÄß
if (attribute[i].GetType().Equals(typeof(byte[])))
{
Console.Write(Encoding.UTF8.GetString((byte[])attribute[i]) + "; ");
}
else
{
Console.Write(attribute[i] + "; ");
}
}
Console.WriteLine();
}
Console.WriteLine();
}
}
}
}
이제 특수 문자가 Yealink T48G에 올바르게 표시됩니까? – boboes
전화의 웹 인터페이스에서 프로토콜 버전을 버전 3으로 설정 한 경우 예. –