本文介绍了从 LDAP 查询用户组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
如何在 C# .NET for ASP 中从 LDAP 活动目录中获取用户组.在我的场景中,我想将用户名传递给从 LDAP 活动目录查询的方法,并告诉我我的用户是该用户组的成员.请帮助我
How To Get User group of user from LDAP active directory in C# .NET for ASP. In my Scenario I want to Pass user name to method which query from LDAP Active directory and tell me my user is Member of This User Groups. Please help me in this
推荐答案
如果您使用的是 .NET 3.5 或更高版本,您还可以使用新的 System.DirectoryServices.AccountManagement (S.DS.AM) 命名空间.
If you're on .NET 3.5 or newer, you can also use the new System.DirectoryServices.AccountManagement (S.DS.AM) namespaces.
有了这个,您可以执行以下操作:
With this, you can do something like:
// create context for domain
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find the user
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, "YourUserName");
if(up != null)
{
// get groups for that user
var authGroups = up.GetAuthorizationGroups();
}
阅读有关新 S.DS.AM 命名空间的更多信息:
Read more about the new S.DS.AM namespace:
在 .NET Framework 3.5 中管理目录安全主体
这篇关于从 LDAP 查询用户组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)