Click here to Skip to main content
13,093,097 members (68,239 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Below details (sample) given by customer. With the given details I would like to confirm that I could successfully connect with the LDAP with the given credentials. How to ensure that?

Please note that we are using C#.NET as development language. Thanks in advance.

UserName: MyUser
Password: Sensitive

Bind Account:
Posted 4-Oct-12 20:50pm
Updated 4-Oct-12 21:57pm
Zoltán Zörgő 5-Oct-12 2:54am
Not clear: if your code is working, than connection is successful. Isn't it?
PS: it is urgent for you, not for us, please don't urge.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You can try similar to this if you want to create an LDAP connection. This worked for me in my app.
LdapConnection ldapConn = new LdapConnection(string.Format("{0}:{1}", "Your Server Name", "3268"));
ldapConn.SessionOptions.PingLimit = 500;
ldapConn.Credential = new NetworkCredential(username, password, domain);
ldapConn.AuthType = AuthType.Negotiate;
ldapConn.SessionOptions.Sealing = true;
ldapConn.SessionOptions.Signing = true;
ldapConn.Timeout = TimeSpan.FromHours(2);
catch (LdapException ldapEx)
   //exception handling

Or if you want to validate only the credentials you can try this
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
   if (!context.ValidateCredentials(userName, password, ContextOptions.ServerBind))
       // put your logic here.

If the solution worked for you, please vote :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If you have access to that LDAP server, you can test it with an existing tool, like LdapAdmin[^]. But if you don't have access, you have to believe, or it is not your concern, it is theirs, to give you proper credentials.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100