View Full Version : How to do this in Grails?
joseluis87
Apr 20th, 2011, 10:27 AM
http://static.springsource.org/spring-security/site/faq/faq.html#faq-ldap-authentication
If I paste this code (with my AD config) in a controller, Grails says that don't like the "Context" property.
¿How can I test the spring-security-ldap config? I have the data on Config.groovy but login says "Sorry, we were not able to find a user with that username and password."
Config.groovy:
grails.plugins.springsecurity.ldap.context.manager Dn = 'uid=Manager,ou=bst,dc=mycompany,dc=com'
grails.plugins.springsecurity.ldap.context.manager Password = 'passwd'
grails.plugins.springsecurity.ldap.context.server = 'ldap://[ActiveDirectoryIP]:[port]'
grails.plugins.springsecurity.ldap.search.base = 'ou=group,dc=mycompany,dc=com'
What's wrong??
Thank's
pledbrook
Apr 21st, 2011, 02:38 AM
Add "import javax.naming.Context" to your controller class and try that test again.
joseluis87
Apr 21st, 2011, 02:49 AM
Add "import javax.naming.Context" to your controller class and try that test again.
[LDAP: error code 49 - Invalid Credentials]
I want to authenticate against an LDAP server but I fail again and again :(
I tried with spring-security-ldap but login form says "Sorry, we were not able to find a user with that username and password."
I don't know what should I do...
Thanks for help, pledbrook
pledbrook
Apr 21st, 2011, 02:54 AM
This seems to be a configuration problem for your Active Directory service. I suggest searching the web for information on connecting to Active Directory through Java & LDAP. I found this forum thread (http://forums.devshed.com/ldap-programming-76/active-directory-services-using-java-api-89586.html) that may help.
joseluis87
Apr 21st, 2011, 04:49 AM
Ok, I run this code in a pure Java project and has not throwed any exception,so it should be properly configured (I've verified the config data in the LDAP server).
I may be forgetting something, I have done the following:
- grails install-plugin spring-security-core
- grails s2-quickstart
- grails install-plugin spring-security-ldap
- Config.groovy:
grails.plugins.springsecurity.ldap.context.manager Dn = 'cn=Manager,dc=mycompany,dc=com'
grails.plugins.springsecurity.ldap.context.manager Password = 'passwordManager'
grails.plugins.springsecurity.ldap.context.server = 'ldap://192.168.X.XX:389'
grails.plugins.springsecurity.ldap.search.base = 'dc=mycompany,dc=com'
grails.plugins.springsecurity.ldap.authorities.gro upSearchBase ='o=group,dc=mycompany,dc=com'
- Run app and go to "LoginController"
- Try login with a user stored at o=group in the Active Directory.
- I get the message "Sorry, we were not able to find a user with that username and password."
Is something missing? I have to modify some class? some authentication function?
Thank you very much
pledbrook
Apr 21st, 2011, 08:55 AM
It could be the username configuration. Check out the Spring Security documentation (http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html#d0e5924) on this as well as the plugin guide (http://burtbeckwith.github.com/grails-spring-security-ldap/docs/manual/index.html). Looks like the plugin defaults to a search pattern of "(uid={0})". Not sure what the user search base is. If you still run into issues, raise the question in the Security plugins sub-forum (http://grails.org/plugins/forum/).
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.