Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. LdapConnection ldapConnection = new LdapConnection(new LdapDirectoryIdentifier("<ipaddress>:<port>"));
  2. ldapConnection.AuthType = AuthType.Basic;
  3.  
  4. LdapSessionOptions options = ldapConnection.SessionOptions;
  5. options.SecureSocketLayer = true;
  6. options.ProtocolVersion = 3;
  7.  
  8. X509Certificate cert = new X509Certificate();
  9. cert.Import(@"E:client.crt");
  10.  
  11. ldapConnection.ClientCertificates.Add(cert);
  12. ldapConnection.Credential = new NetworkCredential("administrator", "xxxxxxxxxx");
  13.  
  14. ldapConnection.Bind();
  15. Console.WriteLine("successfully connected");
  16.  
  17. LdapConnection ldapConnection = new LdapConnection(server + ":" + port);
  18. ldapConnection.AuthType = AuthType.Basic;
  19. ldapConnection.Credential = new System.Net.NetworkCredential(username,
  20. password);
  21. ldapConnection.SessionOptions.ProtocolVersion = 3;
  22. if (sslEnabled)
  23. {
  24. ldapConnection.SessionOptions.SecureSocketLayer = sslEnabled;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement