0
給定一個AD條目,如何獲取用戶的完整合格域名?從用戶AD條目中獲取完整合格域名
到現在爲止我用
((string)directoryEntry.Properties["userPrincipalName"].Value).Split('@')[1]
但userPrincipalName
是不是必需的屬性,所以我想我需要一個備用的......
給定一個AD條目,如何獲取用戶的完整合格域名?從用戶AD條目中獲取完整合格域名
到現在爲止我用
((string)directoryEntry.Properties["userPrincipalName"].Value).Split('@')[1]
但userPrincipalName
是不是必需的屬性,所以我想我需要一個備用的......
我相信,「CN」是在公元強制屬性,根據我的經驗,它與登錄值具有相同的值,因此您可以嘗試。 雖然我不是100%確定,所以試試吧,讓我們知道,如果不是,我會刪除這個答案。
希望它有幫助。
以我的示例用戶'userPrincipalName'爲'matslehmann @ intra.contoso.com','cn'爲'Mats Lehmann',我需要域名,即'intra.contoso.com'。但thx的嘗試。 – Alexander 2014-10-20 13:57:01
也許是sAMAccountName?也是強制的。看看這個網站的更多屬性:http://www.kouti.com/tables/userattributes.htm – Koen 2014-10-20 14:02:28