Click here to Skip to main content
14,243,279 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Guys,

I’m trying to write a programme that will show the values of attributes of user’s accounts in AD. Obviously strings and ints can just be shown as a string but i was looking for a way to determine the datatype first so it could be converted into a string - such as a large integer, octet string UTC time etc.
Any ideas on how i can query for the datatype?

Many Thanks,
Phil
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

All object has the .GetType() function, that returns a Type class and there by the type.

Perhaps this can help ?

Howto: (Almost) Everything In Active Directory via C#[^]

Try take a look at TypeDescriptor class and the function GetConverter and ConvertToString.
   
v3
Comments
Dylan Morley 11-Apr-11 7:24am
   
yeah good article, I still refer to that!
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi Kim,

that doesn't work, but i think i have found my own answer:

ActiveDirectorySchema ass = ActiveDirectorySchema.GetCurrentSchema();
ActiveDirectorySchemaClass u = ass.FindClass("person");

foreach (ActiveDirectorySchemaProperty a in u.GetAllProperties())
{
   Console.WriteLine(a.CommonName + " : " + a.Syntax);
}


i needed the "Syntax" so i could then know how to convert the data.

thank for your help

Phil
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100