I have followed this link C# LDAP query to retrieve all users in an organisational unit and "A referral was returned from the server" exception when accessing AD from C#
I need to know what I am doing wrong in my LDAP path ?
// create your domain context and define what container to search in - here OU=Employees
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "MS", "OU=Employees,DC=CompanyName,DC=com");
// define a "query-by-example" principal - here, we search for a UserPrincipal
// that is still active
UserPrincipal qbeUser = new UserPrincipal(ctx);
qbeUser.Enabled = true;
// create your principal searcher passing in the QBE principal
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
// find all matches
foreach (var found in srch.FindAll())
{
// do whatever here - "found" is of type "Principal" - it could be user, group, computer.....
}
I Need all users detail (Name, Email, Designation, Department) in the current organisation using C# and display those in a dropdownlist. Please help.