komodosp
komodosp

Reputation: 3616

How to tell if ActiveDirectory connection is using LDAP?

Apologies if this is a basic question, but I am in charge of an application that does an Active Directory query and have been asked if it uses LDAP. Unfortunately I know very little about the subject. I'm wondering how I would tell this.

...if we take this snippet of C# code:

using (PrincipalContext AD = new PrincipalContext(ContextType.Domain, Domain.Value, UserName.Value, Password.Value))
{
    UserPrincipal u = new UserPrincipal(AD);
    PrincipalSearcher search = new PrincipalSearcher(u);

    UserPrincipal sr = (UserPrincipal)search.FindAll().
                                             Where(c => c.SamAccountName.ToLower() == UserName.Value.ToLower()).
                                             FirstOrDefault();

The person who wrote this code has left the company.

Domain.Value is just a string containing a Windows domain.

I've done a bit of searching but all I've been able to tell so far is that LDAP is a protocol used by ActiveDirectory, but I don't know how to identify whether this particular connection is using LDAP, or perhaps ActiveDirectory always uses LDAP and the question is irrelevant?

How would I tell this?

Upvotes: 0

Views: 321

Answers (1)

noel
noel

Reputation: 543

The PrincipalSearcher should provide a method GetUnderlyingSearcher which should return a DirectorySearcher.

From the documentation:

Use a DirectorySearcher object to search and perform queries against an Active Directory Domain Services hierarchy using Lightweight Directory Access Protocol (LDAP).

I've not used System.DirectoryServices though so I'd advice some more investigation specifically on which authentication method is used.

Upvotes: 1

Related Questions