Directory Services

Octet String (SID) Property Type

In the underlying ADSI, octet strings and SIDs use the ADSTYPE_OCTET_STRING property type. This property type is a byte array.

Note  In the Active Directory Schema, the syntax name used for octet strings is called String(Octet) and is represented in the Syntax row of attribute tables with the Syntax ID: 2.5.5.10. The syntax name used for SIDs is called String(Sid) and is represented in the Syntax row of attribute tables with the Syntax ID: 2.5.5.17.

The following code example shows how to read the object SID property.

[Visual Basic .NET]
usrSID = CType(usr.Properties("objectSID").Value, Byte())
Dim b As Byte
For Each b In  usrSID
	Console.Write("{0:x2}", b)
Next b
[C#]
usrSID = (byte[])usr.Properties["objectSID"].Value;
foreach(byte b in usrSID)
{
   Console.Write("{0:x2}", b);
}

The following code example shows how to write the object SID property.

[Visual Basic .NET]
Dim usrSID As Byte() = CType(usr.Properties("objectSid").Value, Byte())
usr.Properties("singleSID").Clear()
usr.Properties("singleSID").Add(usrSID)
usr.CommitChanges()
[C#]
byte[] usrSID = (byte[])usr.Properties["objectSid"].Value;
usr.Properties["singleSID"].Clear();
usr.Properties["singleSID"].Add( usrSID ); 
usr.CommitChanges();