AD property value data type is String or byte[]

I was trying to read a property value from the user schema of an Active Directory, the mystery is that the value data type sometimes comes as byte[] & sometimes as String. As much as I do not like it, I have to rely on the type for further processing..

System.Type type = objectTemp.GetType();
    if (type == typeof(String))                    
          this.property1= objectTemp.ToString();

    if (type == typeof(byte[]))
    {   
       this.property1= System.Text.Encoding.Default.GetString((byte[])objectTemp);                  
    }         
Advertisements
Posted in Active Directory

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: