Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LdapDirectoryIdentifier ldap_id = new LdapDirectoryIdentifier(
- host,
- Int32.Parse(port),
- true,
- false);
- LdapConnection con = new LdapConnection(ldap_id);
- con.AuthType = AuthType.Kerberos;
- con.SessionOptions.Sealing = true;
- con.SessionOptions.Signing = true;
- con.SessionOptions.ProtocolVersion = 3;
- con.Bind();
- LdapDirectoryIdentifier ldapIdentifier = new LdapDirectoryIdentifier(
- host,
- Int32.Parse(port),
- true,
- false);
- NetworkCredential credential = new NetworkCredential(username, password);
- LdapConnection con = new LdapConnection(ldapIdentifier, credential, AuthType.Kerberos);
- con.SessionOptions.Sealing = true;
- con.SessionOptions.Signing = true;
- con.SessionOptions.ProtocolVersion = 3;
- con.Bind();
- var networkCredential = new NetworkCredential(connectionAccountName, connectionAccountPassword);
- LdapDirectoryIdentifier ldapDirectoryIdentifier = null;
- switch (connectionType)
- {
- case LDAPConnectionType.SSL:
- ldapDirectoryIdentifier = new LdapDirectoryIdentifier(ldapServerName, Convert.ToInt16(LDAPPorts.SSL));
- ldapConnection = new LdapConnection(ldapDirectoryIdentifier, networkCredential, authType);
- ldapConnection.SessionOptions.ProtocolVersion = 3;
- ldapConnection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
- ldapConnection.SessionOptions.SecureSocketLayer = true;
- break;
- case LDAPConnectionType.TLS:
- ldapDirectoryIdentifier = new LdapDirectoryIdentifier(ldapServerName, Convert.ToInt16(LDAPPorts.Default));
- ldapConnection = new LdapConnection(ldapDirectoryIdentifier, networkCredential, authType);
- ldapConnection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(ServerCallback);
- ldapConnection.SessionOptions.StartTransportLayerSecurity(null);
- break;
- default:
- ldapDirectoryIdentifier = new LdapDirectoryIdentifier(ldapServerName, Convert.ToInt16(LDAPPorts.Default));
- ldapConnection = new LdapConnection(ldapDirectoryIdentifier, networkCredential, authType);
- break;
- }
- ldapConnection.Bind();
Add Comment
Please, Sign In to add comment