0

AD を使用して開発サーバーをセットアップしました。.NET 経由で接続する方法を見つけようとしています。AD がインストールされているのと同じマシンで作業しています。AD から DC 名とマシンの名前を取得しましたが、接続が機能しません。サーバーへの接続に使用したのと同じ資格情報を使用しています。

助言がありますか?

DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://[dc.computername.com]", "administrator", "[adminpwd]");
4

2 に答える 2

0

System.DirectoryServices.Protocols名前空間を使用して、次のようなことを試してください。

//Define your connection
LdapConnection ldapConnection = new LdapConnection("123.456.789.10:389");

try
{
      //Authenticate the username and password
      using (ldapConnection)
      {
          //Pass in the network creds, and the domain.
          var networkCredential = new NetworkCredential(Username, Password, Domain);
          //Since we're using unsecured port 389, set to false. If using port 636 over SSL, set this to true.
          ldapConnection.SessionOptions.SecureSocketLayer = false;
          ldapConnection.SessionOptions.VerifyServerCertificate += delegate { return true; };
          //To force NTLM\Kerberos use AuthType.Negotiate, for non-TLS and unsecured, use AuthType.Basic
          ldapConnection.AuthType = AuthType.Basic;
          ldapConnection.Bind(networkCredential);
      }
      catch (LdapException ldapException)
      {
          //Authentication failed, exception will dictate why
      }
}
于 2013-09-23T03:49:44.177 に答える