views:

324

answers:

2

Does anyone know how to use the credential cache or network credential to get the user's personal info from the Active Directory using C# or VB? I need to get personal info such as name, telephone ID and so on.

+2  A: 

See the System.DirectoryServices class documentation.

Cade Roux
+1  A: 
DirectorySearcher ds = new DirectorySearcher("LDAP://DC=test,dc=com");
ds.Filter = String.Format("&(samaccountname={0})(objectcategory=user)",Environment.Username);
ds.PropertiesToLoad.Add("telephoneNumber");
ds.PropertiesToLoad.Add("Name");
// add all properties here
DirectoryEntry de = ds.FindOne();

By default a user will have sufficent rights to read their own personal details.
If they do not you may need to use Delegation on your directory to allow SELF read access to extra attributes

benPearce