2014-01-11 28 views
2

我們試圖使用Spring安全性對我們的企業LDAP進行身份驗證。我正在使用ActiveDirectoryLdapAuthenticationProvider。下面是從Spring配置文件中的片段:Spring ActiveDirectoryLdapAuthenticationProvider handleBindException - 提供的密碼無效錯誤

<security:authentication-manager erase-credentials="true"> 
    <security:authentication-provider ref="ldapActiveDirectoryAuthProvider"/> 
</security:authentication-manager> 

<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider"> 
<constructor-arg value="DC=xxx,DC=ds,DC=yyy,DC=com" /> 
<constructor-arg value="ldap://xxx.ds.yyy.com:389" /> 
<property name="convertSubErrorCodesToExceptions" value="true"/> 
</bean> 

我越來越:ActiveDirectoryLdapAuthenticationProvider handleBindException Active Directory身份驗證失敗:提供的密碼無效的錯誤。

我的理解是,這是因爲LDAP綁定失敗,因爲它正在尋找userDN /憑證。我們如何在配置文件中指定這些信息?

在使用ActiveDirectoryLdapAuthenticationProvider之前,我使用了<ldap-authentication-provider>DefaultSpringSecurityContextSource。在配置DefaultSpringSecurityContextSource bean時,我能夠指定userDN /密碼。有人可以告訴我如何在使用ActiveDirectoryLdapAuthenticationProvider進行配置時指定userDn和密碼?

回答

5

看起來你可能對ActiveDirectoryLdapAuthenticationProviderhow to configure it有些困惑。它使用類似電子郵件的名稱進行綁定,格式爲[email protected],其中domain.com是您在第一個構造函數中提供的參數。它不使用標準的LDAP DN。這是特定於Active Directory而不是標準LDAP的一部分。 你可能也想看看the source和Javadoc的課程。

如果你已經有一個標準的LDAP認證配置與你的設置一起工作,那麼目前還不清楚你爲什麼想要改變。你可能更好地堅持你所擁有的,因爲它不會與ActiveDirectoryLdapAuthenticationProvider直接兼容。

+0

感謝您的解釋和URL盧克!所有這一切現在都有道理。出於某種原因,我認爲使用ActiveDirectoryLdapAuthenticationProvider是正確的實施方式。看起來我錯了。 – ignatan

相關問題