簡體   English   中英

從Active Directory獲取用戶角色/組 - mvc3

[英]Getting user roles/groups from 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中與用戶和群組玩游戲變得非常容易!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM