Getting securityIdentifier (sID)

Mar 5, 2008 at 9:58 PM
I cannot seem to get the securityIdentifier. Here is my code for my property:

DirectoryAttribute("securityIdentifier")
public string sID { get; set; }

What am I doing wrong?
Mar 28, 2008 at 6:16 PM
Fixed it. But the solution is not intuitive.

It seems that you cannot use any other Type to define the objectSid other than "object". So in order to get teh actual sID, I added another property. Unfortunately, you cannot have ANY other properties on a type with the DirectorySchema attribute that does not exist in AD (it will throw an exception indicating that the property can't be found). This is OK; just add the DirectoryAttribute again with the same property name, but don't define anything in the set block.

DirectorySchema("user", typeof(IADsUser))
public class ADUser*
{
DirectoryAttribute("objectSid")
public object rawsID { get; set; }

DirectoryAttribute("objectSid")
public object sID
{
get
{
SecurityIdentifier s = null;

try
{
if (rawsID != null)
s = new SecurityIdentifier((Byte[])rawsID, 0);
}
catch { }

return s.ToString();
}
set
{

}
}
}

Apr 3, 2008 at 12:50 PM
It's works and also very fast and good!!
Thanks you solve me a lot of problem!