c 獲取AD賬戶資訊

2022-04-06 12:24:16 字數 1597 閱讀 9531

1、獲取連線語句

2、獲取相關資訊

3、搜尋資訊

3、遍歷資訊

注意:遍歷的電腦必須加入域環境

ipglobalproperties ipglobalproperties =ipglobalproperties.getipglobalproperties();

string doname =ipglobalproperties.domainname;

principalcontext principalcontext = new principalcontext(contexttype.domain, doname, "

sunhaiming

", "

zhang.1219");

computerprincipal computerprincipal = new

computerprincipal(principalcontext);

userprincipal userprincipal = new

userprincipal(principalcontext);

principalsearcher principalsearcher = new

principalsearcher(userprincipal);

principalsearcher = new

principalsearcher(computerprincipal);

stringbuilder sb = new

stringbuilder();

foreach (computerprincipal computerprincipalsearchresult in

principalsearcher.findall())

", computerprincipalsearchresult.userprincipalname));

string.format("

描述:"

, computerprincipalsearchresult.description));

string.format("

是否啟用:

", computerprincipalsearchresult.enabled));

string.format("

sam賬號名:

", computerprincipalsearchresult.samaccountname));

string.format("

名稱:"

, computerprincipalsearchresult.name));

string.format("

", computerprincipalsearchresult.lastlogon));

}computerprincipal.dispose();

console.writeline(sb.tostring());

view code

連線驗證語句:if (principalcontext.validatecredentials("sunhaiming", "zhang.1219"))

也可以使用directorysearcher  directoryentry  類

AD 檢視賬戶資訊命令 Get aduser

從ad匯出所有啟用的郵箱列表 1 get aduser filter properties select name,samaccountname,displayname,userprincipalname,surname,givenname 匯出禁用的 ad 賬戶,以日期為準進行排序 1get ad...

ASP 驗證 查詢AD域賬戶資訊

函式功能 查詢域使用者資訊 引數說明 stradmin 域管理賬戶 password 域帳戶密碼 domain 域伺服器。參考資料 搜尋 query ldap for existing user classic asp 在 www.experts exchange.com function geta...

C 與Windows使用者賬戶資訊的獲取

console.writeline environment.username 計算機netbios名稱 console.writeline environment.machinename 計算機網路網域名稱稱 console.writeline environment.userdomainname ...