2008-10-07 126 views
0

有誰知道如何使用憑據緩存或網絡憑據從Active Directory使用C#或VB獲取用戶的個人信息?我需要獲取個人信息,例如姓名,電話ID等。憑證緩存

回答

1
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(); 

默認情況下,用戶將有足夠的權利閱讀他們自己的個人信息。
如果他們不需要,您可能需要在您的目錄上使用授權,以允許SELF讀取訪問額外屬性