![](/img/trans.png)
[英]Get all userids in an active directory group using page control in an LDAP - Native api
[英]What is the proper way to get some specific user attributes from Active Directory via LDAP C API?
我正在嘗試使用Windows LDAP API從Active Directry獲取一些用戶屬性。 我在用:
例如:
PCHAR myAttributes[4];
myAttributes[0] = "DistinguishedName";
myAttributes[1] = "DisplayName";
myAttributes[2] = "PasswordExpired";
myAttributes[3] = "mail";
ldap_search_s(
myLdapConnection, // Ldap connection
myDomain, // DN to start search
LDAP_SCOPE_SUBTREE, // Scope
myFilter, // Filter
myAttributes, // Retrieve list of attributes
0, // Get both attributes and values
&mySearchResult // [out] Search results
);
它返回DistinguishedName
, DisplayName
和mail
屬性,但不會重新返回PasswordExpired
屬性。
我查詢了其他一些屬性,看起來它沒有返回帶有布爾值的屬性以及EmailAddress
屬性。
PasswordExpired
屬性? EmailAddress
呢? EmailAddress
和mail
之間有區別嗎? Active Directory中沒有PasswordExpired LDAP屬性。 要構建查詢,請在標准Active Directory架構https://msdn.microsoft.com/en-us/library/ms675090(v=vs.85).aspx中查看此URL,以獲取屬性名稱。 要檢查給定帳戶的密碼是否已過期,您需要檢查userAccountControl屬性,該屬性實際上是存儲用戶帳戶不同狀態的值的標志https://msdn.microsoft.com/zh-cn/library/ms680832(v= vs.85).aspx 。 如果您不必僅遵循LDAP https://msdn.microsoft.com/zh-cn/library/aa746343(v=vs.85).aspx ,有IADsUser界面可以為您翻譯所有內容。
您將在mail屬性中找到當前的主要電子郵件地址。 沒有EmailAddress LDAP屬性,除非您所指的E-mail-Addresses是CN,與郵件具有相同的架構屬性,所以在此沒有區別。
往上看。 通常,如果您沒有令人信服的理由僅堅持使用C / LDAP,我建議您改用.Net Framework。 否則,您還有很多工作要做-不僅要解釋位標志(如密碼過期),還可能需要使用不同的身份驗證方法,捕獲時間和日期的不同結構,考慮時區,UTF,跟蹤引薦和其他內容需要取決於您要實現的復雜性。 在.Net Framework中,您的生產效率將大大提高。 請參閱DirectoryServices https://msdn.microsoft.com/en-us/library/mt481534(v=vs.110).aspx名稱空間或安全名稱空間https://msdn.microsoft.com/en-us/library/mt481561( v = vs.110).aspx了解詳情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.