简体   繁体   中英

Implementing LDAP authentication in grails with spring-security-core-ldap plugin?

I am currently looking into creating an application within Grails and I have created the app and installed both plugins below:

http://grails.org/plugin/spring-security-ldap http://grails.org/plugin/spring-security-core

I then went ahead and run the following command in order to get the security core setup:

grails s2-quickstart com.smstool User Role

That then created all the necessary controllers, views and models I would need. From there I then went on to update the config.groovy file with the following options:

grails.plugins.springsecurity.ldap.authorities.groupSearchBase = 'DC=MYLOCATION, DC=COM'
grails.plugins.springsecurity.ldap.authorities.retrieveDatabaseRoles = false
grails.plugins.springsecurity.ldap.authorities.ignorePartialResultException = true // typically needed for Active Directory
grails.plugins.springsecurity.ldap.search.base = 'DC=MYLOCATION, DC=COM'
grails.plugins.springsecurity.ldap.search.filter="sAMAccountName={0}" // for Active Directory you need this
grails.plugins.springsecurity.ldap.search.searchSubtree = true
grails.plugins.springsecurity.ldap.auth.hideUserNotFoundExceptions = false
grails.plugins.springsecurity.ldap.search.attributesToReturn = ['mail', 'displayName'] // extra attributes you want returned; see below for custom classes that access this data
grails.plugins.springsecurity.providerNames = ['ldapAuthProvider', 'anonymousAuthenticationProvider'] // specify this when you want to skip attempting to load from db and only use LDAP

// role-specific LDAP config 
grails.plugins.springsecurity.ldap.useRememberMe = false 
grails.plugins.springsecurity.ldap.authorities.retrieveGroupRoles = true 
grails.plugins.springsecurity.ldap.authorities.groupSearchBase = 'DC=MYLOCATION, DC=COM'

I then ran the application and went to the Login page that was created when i run the first command (s2-quickstart), however when I try to enter my LDAP details I do not get an error however it says the username doesn't exist.

I think this may be due to the fact that there is further configuration needed to get this LDAP functionality to work and the details the user enters are not being passed correctly, also I am new to Grails :-).

I think I may have to do something like create a "UserDetailsContextMapper" however I do not know how to do this and I have looked at the link below but cant seem to grasp what I need to do:

http://grails-plugins.github.com/grails-spring-security-ldap/docs/manual/guide/2.%20Usage.html

Is there anyone who can help me understand the link above or who knows the steps I should take to properly authenticate against LDAP??

Thanks in advance :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM