Jun 06, 2011 04:34 PM|justsnafu|LINK
Note, this is coded against opends, not AD but after searching google the same problem appears to occur on AD occasionally as well.
Basically I've created some custom objectClasses and attributes on our LDAP instance to represent our specific business needs. For example I've created a custom 'user' class that subclasses the LDAP standard 'person' object and adds a few custom attributes
to it. For example I've added an attribute called departmentId that has specific meaning to our organization. This attribute is defined in the ldap schema according to RFC standards to use the INTEGER syntax type (220.127.116.11.4.1.1418.104.22.168.27).
But when I query for that specific user I get two different behaviors based on the type of attribute I'm pulling back:
1)if its an ldap core attribute (say 'cn' or 'uid', etc), I can do this:
SearchResult result = srch.FindOne();
string uid = result.Properties["uid"] as string;
2)if its a custom attribute type (of any data-type) it will always come back as a byte array. Now I can easily reconstitue that byte array to its string representation like this:
byte bytes = result.Properties["departmentId"] as byte
string strValue = Encoding.Default.GetString(bytes);
but why do I have to? This doesn't make much sense to me