2017-04-24 6 views
0

다음 코드로 Active Directory에서 사용자/암호의 유효성을 검사하는 Windows 응용 프로그램이 있습니다. PrincipalContext :: ValidateCredentials가 잘못된 암호로 LdapException을 throw합니다.

PrincipalContext^ pc = gcnew PrincipalContext(ContextType::Domain); 
// validate the credentials 
bool isValid = pc->ValidateCredentials(userName, password); 
if(!isValid) 
{ 
    throw gcnew SecurityTokenValidationException("Invalid user ID/password"); 
} 

UserPrincipal^ upUser = UserPrincipal::FindByIdentity(pc, userName); 
if(upUser && !upUser->IsMemberOf(pc, IdentityType::SamAccountName, ADGroup)) 
{ 
    String^ msg = "User " + userName + " is not a member of the " + ADGroup + " group."; 
    throw gcnew SecurityTokenValidationException(msg); 
} 

내가 유효한 사용자 만 유효 passwordd,은 ValidateCredentials을 (주면) 2008/.NET 3.5/32 비트 빌드 비주얼 스튜디오에서이 코드를 실행 false를 반환합니다. 2013/.NET 4.0/64 비트 빌드 비주얼 스튜디오를 사용

는 동일한 코드는 LDAP 예외가 발생합니다 : 내가 네트워크에서 내 PC를 분리하면

System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable. 
at System.DirectoryServices.Protocols.LdapConnection.Connect() 
at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential) 
at System.DirectoryServices.AccountManagement.CredentialValidator.lockedLdapBind(LdapConnection current, NetworkCredential creds, ContextOptions contextOptions) 
at System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions) 
at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password) 
at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password) 
at soapcon.ADUserNameValidator.Validate(String userName, String password) 

, 나는이 PrincipalServerDownException 예외가를, 그래서 나는 실제로 우리 광고 서버와 이야기하고 있다고 확신합니다.

이 코드는 내 코드, .NET 문제 또는 상당히 오래된 Active Directory 서비스 (Windows 2000) 때문에 발생합니까?

+0

. BTW, IIS 구성에서 도메인 acount에서 실행되는 응용 프로그램 풀입니까? IIS는 Cassiny와 다르게 동작합니다. – bradbury9

+0

@ bradbury9 저는 IIS를 실행하지 않고 있으며 개발자 도메인 계정으로 실행되는 Windows 응용 프로그램입니다. –

+0

다른 프레임 워크가 다른 기본 인증 옵션을 사용하는지 궁금합니다. 두 경우 모두'.ValidateCredentials (String, String, ContextOptions)'오버로드를 시도 할 수 있습니까? – bradbury9

답변

1

다른 프레임 워크가 다른 기본 인증 옵션을 사용한다면 두 경우 모두 .ValidateCredentials (String, String, ContextOptions) 과부하를 시도 할 수 있습니까?

의견에 따라 경찰, 과부하이 ContextOptions 플래그를 시도 :

`C#을`그러나`C++ .net`하지
ContextOptions::Negotiate | ContextOptions::Signing | ContextOptions::Sealing 
관련 문제