diff options
Diffstat (limited to 'src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java')
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java b/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java index 3ad8957..63ce60a 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java +++ b/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java @@ -75,7 +75,7 @@ public class LdapSearch extends SystemCommandTask } } String filter; - if ( this.filter == null ) { + if ( this.filter == null || this.filter.isEmpty() ) { status.addMessage( "Trying to find 4 random AD users to verify everything is all right..." ); if ( this.plainldap ) { filter = "(&(objectClass=posixAccount)(uid=*))"; @@ -88,6 +88,7 @@ public class LdapSearch extends SystemCommandTask } // As we don't care about the certificate here, you might want to put TLS_REQCERT never + status.addMessage( "Using filter: " + filter ); // in /etc/ldap/ldap.conf if ( this.bindpw.isEmpty() ) { return new String[] { @@ -128,8 +129,7 @@ public class LdapSearch extends SystemCommandTask } if ( exitCode == 4 ) // Means size limit exceeded, ignore exitCode = 0; - if ( exitCode != 0 ) - status.addMessage( "Exit code is " + exitCode ); + status.addMessage( "Exit code is " + exitCode ); if ( exitCode == 0 && this.userCount < 4 && !this.getDn ) status.addMessage( "Found less than 4 users. Are you sure you got the right credentials?" ); return this.userCount >= 4 || ( this.getDn && status.dn != null ); @@ -142,23 +142,28 @@ public class LdapSearch extends SystemCommandTask if ( line.startsWith( "uid: " ) ) { status.addMessage( "Found LDAP user " + line.substring( 5 ) + " :-)" ); this.userCount++; + return; } if ( line.startsWith( "uid:: " ) ) { status.addMessage( "Found LDAP user " + line.substring( 6 ) + " :-)" ); this.userCount++; + return; } } else { if ( line.startsWith( "sAMAccountName: " ) ) { status.addMessage( "Found AD user " + line.substring( 16 ) + " :-)" ); this.userCount++; + return; } if ( line.startsWith( "sAMAccountName:: " ) ) { status.addMessage( "Found AD user " + line.substring( 17 ) + " :-)" ); this.userCount++; + return; } } if ( line.startsWith( "dn: " ) ) { status.dn = line.substring( 4 ); + return; } // Figure out if we have homedir if ( this.getDn ) { @@ -183,6 +188,7 @@ public class LdapSearch extends SystemCommandTask if ( score > 10 ) { status.addMessage( "Potential home directory attribute: " + p[0] ); status.home.add( new DirCandidate( p[0], p[1], score ) ); + return; } } } |