-1
在分享點解決方案中,我需要從AD組獲得所有用戶,目前AD組可以有30個用戶,但將來我們可以替換AD一個擁有1000個用戶的組。並且因爲每個用戶在每個請求(其導航組件顯示/隱藏OneDrive鏈接)上都執行此代碼,所以我需要它儘可能高效。如何知道用戶是否在AD組中有效存在
// Get all users from a group recursively.
var context = new System.DirectoryServices.AccountManagement.PrincipalContext(ContextType.Domain);
GroupPrincipal group = new GroupPrincipal(context ,farm.Properties[GlobalNavigationConstants.Keys.GlobalNavigationOneDriveADGroup].ToString());
PrincipalSearchResult<Principal> members = group.GetMembers(true);
var list = members.OfType<UserPrincipal>().ToList();
//Get current user
var loginName = SPContext.Current.Web.CurrentUser.LoginName;
//How to check if loginname is on list efficiently?
我該如何儘可能快地做到這一點?