我设法通过Active Directory使用此代码验证用户
DirectoryEntry entry = new DirectoryEntry(ADPath, domainAndUsername, password);
object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (null == result)
{
return "false";
}
如果用户通过身份验证后我想为此用户创建授权规则以阻止访问我拥有的ApiControllers
我该怎么做?
感谢您的帮助!