當前位置:編程學習大全網 - 腳本源碼 - 如何使用LdapConnection 類(1)鏈接 Ldap服務器

如何使用LdapConnection 類(1)鏈接 Ldap服務器

3 static NetworkCredential credential;4 static string targetOU;5 static string pwd;6 public void LdapBind()7 {8 ldapServer = "172.18.69.204:389";9 targetOU = "cn=Manager,dc=tst,dc=com";10 pwd = "000000";1112 //credential = new NetworkCredential(String.Empty, String.Empty);13 credential = new NetworkCredential(targetOU, pwd);141516 string dn = "";1718 //ldapConnection = new LdapConnection(new LdapDirectoryIdentifier(ldapServer));19 //ldapConnection.SessionOptions.ProtocolVersion = 3;//Ldap協議版本20 //ldapConnection.AuthType = AuthType.Anonymous;//不傳遞密碼進行連接2122 ldapConnection = new LdapConnection(ldapServer);23 ldapConnection.AuthType = AuthType.Basic;24 ldapConnection.Credential = credential;2526 try27 {28 Console.WriteLine("鏈接.");29 ldapConnection.Bind();30 Console.WriteLine("鏈接成功");3132 }33 catch (Exception ee)34 {35 Console.WriteLine(ee.Message);

  • 上一篇:何為視頻監控系統名詞解釋
  • 下一篇:74泡泡美人魚,我找了半天找不到,有人分享嗎?
  • copyright 2024編程學習大全網