System.DirectoryServices.Protocols의 LdapConnection을 사용하여 Active Directory를 쿼리 할 수 있습니까?LdapConnection을 사용하여 AD를 열거 함
PrincipalContext를 인스턴스화하는 데 문제가 있습니다. 나는 동일한 값을 전달하고
PrincipalContext context = new PrincipalContext(
ContextType.Domain,
ldapServer,
null,
useSsl ? ContextOptions.SecureSocketLayer | ContextOptions.SimpleBind : ContextOptions.SimpleBind,
username,
password);
을 사용하고있는 교장 컨텍스트를 인스턴스화하려고 할 때 완벽 이름을 위해,
private LdapConnection getLdapConnection(string username, string password, string ldapServer, bool secured)
{
int port = secured ? 636 : 389;
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier(ldapServer, port, false, false));
if (secured)
{
connection.SessionOptions.ProtocolVersion = 3;
connection.SessionOptions.SecureSocketLayer = true;
}
connection.Credential = new NetworkCredential(username, password);
connection.AuthType = AuthType.Basic;
connection.SessionOptions.VerifyServerCertificate += (conn, cert) => { return true; };
connection.Bind();
return connection;
}
: 여기 내 코드는 누군가가 문제를 발견 할 경우,의 domain\user
의 형식이고 ldapServer의 형식은 server.domain.com
이고 ldapServer의 값은 다음과 같습니다. 주체 컨텍스트를 만들 때 636이 추가됩니다.
연결하려는 서버에 인증 문제가있어 LdapConnection이 확인을 위해 true를 반환하도록 설정되어 있기 때문에이를 방지 할 수 있습니다. 신뢰할 수있는 문제는 아닙니다. 나는 서버에 접근 할 수 없기 때문에 이것을 바꿀 수 없다.
오류가 발생했습니다. –
서버에 연결할 수 없습니다. – Sam
당신의 LDAP 서버를'dc = MyDomain, dc = com'으로 시도하십시오. –