简体   繁体   中英

Active Directory Lightweight Directory Services how to get data from AD DS

I just recently started working with Lightweight Directory Services and I have read many articles but I still have few questions.

My objective is to authenticate users in application using Lightweight Directory Services.

To accomplish the objective I installed Lightweight Directory services using this tutorial.

After completing the steps in the tutorial I was able successfully connect to it using ADSI Edit.

However, as I started looking around I see that this instance is empty. There're no user objects.

I have a full version of Active Directory (2008 R2) installed in my production. How do I get the user data from full version to Lightweight so I can do authentication?

Can this be accomplished using the approach I'm taking, or I'm misunderstanding the concept of Lightweight Directory Services?

Is the concept to validate users in Lightweight Directory Services similar as I would authenticate users through the full version of AD, like the code below?

public string Authenticate(string username, string pwd)
    {
        string domain = "mydomain";
        using (PrincipalContext ad = new PrincipalContext(ContextType.Domain, domain))
        {
            bool isValid = ad.ValidateCredentials(username, pwd);
            string result = isValid.ToString();
            return result;
        }
    }

Note* full active directory is in production sitting behind the firewall, while Lightweight Directory Services is residing in DMZ on the other side of firewall.

var fullName = string.Empty;
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
    using (UserPrincipal user = UserPrincipal.FindByIdentity(context,"racerX")) //User.Identity.Name
    {
        if (user != null)
        {
            fullName = user.DisplayName;
        }
    }
}
  • if the user is in AD then you know that they are validated assuming that their account is properly maintained as well..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM