[英]AD property is System.Byte[] - which Encoding to convert to string?
I am reading the displayName property from ActiveDirectory. 我正在从ActiveDirectory中读取displayName属性。
On Windows Server 2008, result.Properties["displayName"][0].ToString()
is the displayName, while on Windows Server 2012, it returns System.Byte[]
. 在Windows Server 2008上,
result.Properties["displayName"][0].ToString()
是displayName,而在Windows Server 2012上,它返回System.Byte[]
。 Now I have to convert the value using sth like var buffer = result.Properties["displayName"][0]; Encoding.%SomeEncoding%.GetString(buffer, 0, buffer.Length);
现在我必须使用类似于
var buffer = result.Properties["displayName"][0]; Encoding.%SomeEncoding%.GetString(buffer, 0, buffer.Length);
转换值var buffer = result.Properties["displayName"][0]; Encoding.%SomeEncoding%.GetString(buffer, 0, buffer.Length);
var buffer = result.Properties["displayName"][0]; Encoding.%SomeEncoding%.GetString(buffer, 0, buffer.Length);
, ,
but I don't know which Encoding Microsoft chose - UTF, ISO, Default, Local? 但我不知道微软选择哪种编码 - UTF,ISO,默认,本地?
By the way, is there a "cheat sheet" on AD properties and their types available? 那么,AD属性上是否有“备忘单”及其类型?
Active Directory实现LDAP v3并使用UTF-8 。
你可以从AD读取一个字节值,如下所示:
Encoding.UTF8.GetString((byte[])userRow.Properties["mailNickname"][0]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.