具有二进制属性类型的 DN
诸如 Active Directory 架构 wellKnownObjects 特性之类的属性使用 Object(DN-Binary) 语法类型。有关 wellKnownObjects 属性或 Object(DN-Binary) 语法类型的详细信息,请参阅 MSDN Library(网址为 https://go.microsoft.com/fwlink/?LinkID=27252)中的“Well-Known-Objects attribute(Well-Known-Objects 属性)”或“Object(DN-Binary)”主题。
如果使用 Object(DN-Binary) 类型的属性是通过 Properties 属性获取的,则此数据类型表示为可以通过 IADsDNWithBinary 接口访问的 COM 对象。有关此接口的更多信息,请参见位于 https://go.microsoft.com/fwlink/?LinkID=27252 上的 MSDN Library 中的主题“IADsDNWithBinary”(可能为英文网页)。如果使用 Object(DN-Binary) 类型的属性是从 ResultPropertyValueCollection 获取的,则将此数据类型表示为 String 对象,该对象包含可分辨名称以及采用 Object(DN-Binary) 语法指定格式的二进制数据。
下面的示例说明如何读取一个属性,该属性的值使用带有二进制语法的 DN。
Imports ActiveDs
Dim wkObjects As [Object] = usr.Properties("wellKnownObjects").Value
Dim wkObject As DNWithBinary
For Each wkObject In CType(wkObjects, IEnumerable)
Dim bytes As Byte() = CType(wkObject.BinaryValue, Byte())
Dim b As Byte
For Each b In bytes
Console.Write("{0:x2}", b)
Next b
Console.WriteLine(wkObject.DNString)
Next wkObject
using ActiveDs;
Object wkObjects = ent.Properties["wellKnownObjects"].Value;
foreach(DNWithBinary wkObject in (IEnumerable) wkObjects)
{
byte[] bytes= (byte[]) wkObject.BinaryValue;
foreach(byte b in bytes)
{
Console.Write("{0:x2}",b);
}
Console.WriteLine(wkObject.DNString);
}
下面的示例说明如何写入一个属性值,该属性值使用带有二进制语法的 DN。
Imports ActiveDs
Dim dnBin As New ActiveDs.DNWithBinaryClass()
dnBin.DNString = usr.Properties("distinguishedName").Value.ToString()
dnBin.BinaryValue = usr.Guid.ToByteArray()
usr.Properties("singleDNWithBinary").Value = dnBin
usr.CommitChanges()
using ActiveDs;
ActiveDs.DNWithBinary dnBin = new ActiveDs.DNWithBinaryClass();
dnBin.DNString = usr.Properties["distinguishedName"].Value.ToString();
dnBin.BinaryValue = usr.Guid.ToByteArray();
usr.Properties["singleDNWithBinary"].Value = dnBin;
usr.CommitChanges();
另请参见
参考
System.DirectoryServices
DirectoryEntry
ResultPropertyValueCollection
概念
Send comments about this topic to Microsoft.
版权所有 (C) 2007 Microsoft Corporation。保留所有权利。