grails - Connecting to Active directory and searching user -
In the Grails project, I need to connect to Active Directory and search the user (authentication objectives).
I am big in LDAP and Active Directory and using it.
My company gave me a user credentials for testing
OU = vendors, DC = company, DC = Net CN = test -2 sAMAccountName = test2 password = test123 Ip = LDAP: //xx.xx.xx.xx: 389 So what I have tried
LDAP ldapConn = LDAP.newInstance (" LDAP: //xx.xx.xx.xx: 389 "," CN = test-2, OU = vendor, DC = company, DC = net "," test 123 ") {DEF result = ldapConn.search ('(' CN = Test-2) ',' OU = Vendor, DC = Company, DC = Net ', Searchzco .on) println "$ {results.size} entries found:" println result} hold (exception before) {println ex.printStackTrace ()} The above code works and I activate I am using CN = Testing -2 to force the directory, but the employees of the company always use sAMAccountName for login. Therefore, when I tried to bind Ith sAMAccountName = test2 and password
LDAP ldapConn = LDAP.newInstance ("LDAP: //xx.xx.xx. $ {Results.size} "," xx: 389 "," sAMAccountName = test2, OU = vendors, DC = "(" (SAMCountN = test2) "," OU = vendor, DC = company, DC = net ", searchsecope.one } Entries found: "println result} catches {exceptions} {println ex.printStackTrace ()} I'm getting
java Lang.NullPointerException Error | Org.apache.directory.groovyldap.LDAP.search (unknown source) error How can I proceed, test2 user always sAMAccountName (test2) .
OK, you have two different things here. First you have to create a new LDAP example ( LDAP.newInstance ) and the second second search process ( ldapConn.search ). In your example code, you are using the same credentials for both methods. But it should really be: -
LDAP.newInstance - Test for a different
sAMAccountName For the valid connection string ldapConn.search , you therefore have your original work connection string (which includes LDAP.newInstance) ("LDAP: //xx.xx.xx.xx: 38 9", "CN = test2, ... - for starters) and your ldapCon Skip to search sAMAccountName which you want to view. Express Tutorial: Depending on your settings, it may be invalid to connect to the way you have tried it, apart from this, the way of cleaner to check it will be two places, but to make sure the initial connection is working. And only returning the real result search.
The following article contains some information about various LDAP features, which can be useful:
Comments
Post a Comment