程式碼如下

string AD_RootPath = "LDAP://AD的IP或是電腦名稱/cn=Users,dc=網域,例:example,dc=網域,例:com";
DirectoryEntry entry = new DirectoryEntry(AD_RootPath, 帳號,密碼, AuthenticationTypes.Secure); 
DirectorySearcher deSearch = new DirectorySearcher(entry);
foreach (SearchResult res in deSearch.FindAll())
{
        foreach (string key in res.Properties.PropertyNames)
        {
                foreach (object val in res.Properties[key])
                {
                string v=key+"="+val;
                Response.Write(v + "<BR>");
                }
        }
Response.Write( "------------------------------------------------------------------------------------------------<BR>");
}
arrow
arrow
    文章標籤
    C# AD ldap
    全站熱搜

    Empty 發表在 痞客邦 留言(0) 人氣()