I have looked for some threads in this forum but they are not giving any clear solutions to my problem.

I am trying to do a simple authentication thrpugh an LDAP server in my university. however the code returns an exception saying that "the server is not operational".

public bool IsAuthenticated(string username, string password)
        {
            DirectoryEntry dir = new DirectoryEntry("LDAP://servername/ou=People,o=university.edu",username,password,AuthenticationTypes.SecureSocketsLayer);
            try
            {
                using (DirectorySearcher search = new DirectorySearcher(dir))
                {
                    search.ServerTimeLimit = new TimeSpan(0, 0, 5);
                    search.ClientTimeout = new TimeSpan(0, 0, 5);
                    SearchResult result = search.FindOne();
                }
            }

            catch
            {
                return false;
            }

            return true;
        }

any ideas??

Your whole code is not able to be viewed properly on this site
Specially this below line

DirectoryEntry("LDAP://servername/ou=People,o=university.edu",username,password,AuthenticationTypes.Secur

Can u please type it again by breaking this statement in 2 lines

I think i can help u then..mean while i am looking into this problem...

Hello Varsh10;

Yesterday I talked to the superviser of the IT department of my university; and as he had indicated, because of some security issues, I am not allowed to querry the LDAP server of my university since I can retrieve all students passwords by brutal force attack or sth. I am now waiting for the IT's decision, according to my professor, there maybe a exception for me to use the LDAP server with some big responsibilities. Anyway, thanx for the reply and here is the unseen part of the code.

DirectoryEntry dir = new DirectoryEntry("LDAP://servername/ou=People,o=university.edu",
username,password,AuthenticationTypes.SecureSocketsLayer);

ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.