0
我需要能夠將用戶活動目錄組與可接受組列表進行比較。這不是用於身份驗證的。從Active Directory獲取用戶角色/組 - mvc3
我知道我可以使用System.DirectoryServices,但我見過很多說使用AccountManagement的帖子,但我看到的是.Active Directory。
任何人都可以幫助我在正確的方向嗎?
我需要能夠將用戶活動目錄組與可接受組列表進行比較。這不是用於身份驗證的。從Active Directory獲取用戶角色/組 - mvc3
我知道我可以使用System.DirectoryServices,但我見過很多說使用AccountManagement的帖子,但我看到的是.Active Directory。
任何人都可以幫助我在正確的方向嗎?
嘗試這樣:請檢查System.DirectoryServices.AccountManagement
(S.DS.AM)命名空間。在這裏閱讀全部內容:
基本上,你可以定義域範圍內,並可以輕鬆地查找用戶和/或組AD:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
PrincipalSearchResult<Principal> authgroups = user.GetAuthorizationGroups();
// do your checking with the auth groups that the user has - against your list
}
的新的S.DS.AM可以很容易地與AD中的用戶和羣組玩耍!
謝謝!我會嘗試! – mdarling