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)
{
}
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))
{
}
}
If the solution worked for you, please vote :)