2011-03-31 95 views

回答

3

這裏是2篇約C#和活動目錄好文章:

如何訪問AD樣品:

包括System.DirectoryServices.dll程序參考。

DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Environment.MachineName); 
string userNames="Users : "; 
foreach (DirectoryEntry child in directoryEntry.Children) 
{ 
    if (child.SchemaClassName == "User") 
    { 
     userNames += child.Name + Environment.NewLine; 
     PropertyCollection coll = child.Properties; 

     // sample of how to get other values 
     object fullName = coll["FullName"].Value;   
     object nickName = coll["OtherName"].Value;   
    } 

} 
MessageBox.Show(userNames); 

下面是其他屬性的列表,其值可以全身而退:IADsUser Interface

+1

@ na.farzane:我修改實例向您展示如何讓其他瓦萊斯。 – HABJAN 2011-03-31 09:09:14

+0

如何得到我的用戶的用戶名稱,它的暱稱是例如來自活動目錄的「farzane」???謝謝。 – Farna 2011-03-31 09:15:24

+1

@ na.farzane:看看這個:http://www.eggheadcafe.com/articles/20051106.asp,它解釋瞭如何搜索廣告 – HABJAN 2011-03-31 09:31:12

相關問題