Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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.
 

 
DEV LDAP:
------------------
UserName: MyUser
Password: Sensitive
 
Bind Account:
------------------------
uid=MyUser,ou=Application,ou=Infrastructure,dc=MyDomain,dc=com
Posted 4-Oct-12 21:50pm
Edited 4-Oct-12 22:57pm
v2
Comments
Zoltán Zörgő at 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
good
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);
 
try
{
  ldapConn.Bind();
 
}
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 Smile | :)
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 250
1 George Jonsson 175
2 Jochen Arndt 150
3 Kornfeld Eliyahu Peter 149
4 PIEBALDconsult 110
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
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