SOLVED: Unable to authenticate via LDAP to directory (Active Directory) with Spring Security -



SOLVED: Unable to authenticate via LDAP to directory (Active Directory) with Spring Security -

i'm using: - spring 3.1.3

and problem i'm unable connect active directory via ldap using valid credentials.

i don't know if caused malformed pattern or configuration issue userdn or url's rootdn. although , @ first glance , seems correct.

this current spring security config file:

... <security:authentication-manager alias="authenticationmanager"> <security:authentication-provider ref="ldapauthprovider" /> </security:authentication-manager> <bean id="ldapauthprovider" class="org.springframework.security.ldap.authentication.ldapauthenticationprovider"> <constructor-arg> <bean id="bindauthenticator" class="org.springframework.security.ldap.authentication.bindauthenticator"> <constructor-arg ref="contextsource" /> <property name="userdnpatterns"> <list><value>samaccountname={0}</value></list> </property> </bean> </constructor-arg> </bean> <bean id="contextsource" class="org.springframework.security.ldap.defaultspringsecuritycontextsource"> <constructor-arg value="ldap://remotehost:port/ou=my%20company,dc=domain,dc=subdomain"/> <property name="userdn" value="cn=managerusercn,ou=users,ou=test accounts,ou=my company,dc=domain,dc=subdomain/> <property name="password" value="thepass"/> </bean> ...

*i have replaced real urls, organizations, groups, etc descriptive data

*it's requeriment searching samaccountname.

and namingexception throwed doauthentication:bindwithdn next:

*org.springframework.ldap.authenticationexception: [ldap: error code 49 - 80090308: ldaperr: dsid-0c0903a9, comment: acceptsecuritycontext error, info 52e, v1db1*

and 52e code interpretation read on ldap wiki not exclusively right because launching both typing existing username , nonexistent username.

im refering to:

note: returns when username valid password/credential invalid. prevent other errors beingness displayed noted.

not me.

sorry english language , ...

greetings!

i have found reply question.

i got specifiying user-search property in bindauthentication. previusly had tested usersearch alternative without including base of operations directory (first parameter). so, me, it's mandatory , allow authentication works.

in code:

<bean id="ldapauthprovider" class="org.springframework.security.ldap.authentication.ldapauthenticationprovider"> <constructor-arg> <bean id="bindauthenticator" class="org.springframework.security.ldap.authentication.bindauthenticator"> <constructor-arg ref="contextsource" /> <property name="usersearch" ref="usersearch"/> </bean> </constructor-arg> </bean> <bean id="usersearch" class="org.springframework.security.ldap.search.filterbasedldapusersearch"> <constructor-arg> <value>ou=my company,dc=domain,dc=subdomain</value> </constructor-arg> <constructor-arg> <value>(samaccountname={0})</value> </constructor-arg> <constructor-arg ref="contextsource" /> <property name="searchsubtree"> <value>true</value> </property> </bean>

perhaps can help similar issue.

pd: alternative utilize especified activedirectoryldapauthenticationprovider

<bean id="ldapactivedirectoryauthprovider" class="org.springframework.security.ldap.authentication.ad.activedirectoryldapauthenticationprovider"> <constructor-arg value="domain.subdomain" /> <constructor-arg value="ldap://host:port" /> <property name="convertsuberrorcodestoexceptions" value="true"/> </bean>

it seems work fine too.

spring spring-security ldap

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -