【问题标题】:Validating a Active Directory User验证 Active Directory 用户
【发布时间】:2011-08-31 10:54:12
【问题描述】:

要检查用户在 Active Directory 中的存在,使用哪个更好的 .Net 库?

System.Web.Security.ActiveDirectoryMembershipProvider 

System.DirectoryServices

我正在使用System.DirectoryServices,我觉得它正是要使用的那个。我确实看到here 中提供了类似的功能。

请指教。

【问题讨论】:

    标签: c#-4.0 active-directory


    【解决方案1】:

    由于您使用的是 .NET 4.0,因此您应该查看 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)
    {
       // do something here....     
    }
    

    新的 S.DS.AM 让在 AD 中与用户和组一起玩变得非常容易!

    【讨论】:

    • 是的,没错。我的问题是我可以将 System.Web.Security.ActiveDirectoryMembershipProvider 用于类似目的吗?
    • @Nilaa:这是 ASP.NET 成员资格提供程序 - 需要单独正确配置,不确定是否可以在没有所有设置和所有内容的情况下使用它。我不会使用它 - 除非你已经在使用 ASP.NET 成员资格的东西......
    猜你喜欢
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2011-01-22
    • 2010-09-22
    • 2017-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多