summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/auth/LdapAuthProvider.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-04-08 00:21:40 -0400
committerJames Moger <james.moger@gitblit.com>2014-04-08 00:21:40 -0400
commitef4c45a4b129e77f1755d82b1a72372277bd95c8 (patch)
tree7534e7103751b9f011388eabb531bf2cc9d00e9d /src/main/java/com/gitblit/auth/LdapAuthProvider.java
parent90c354f5760edde96d44556f3bc8e9e630777029 (diff)
downloadgitblit-ef4c45a4b129e77f1755d82b1a72372277bd95c8.tar.gz
gitblit-ef4c45a4b129e77f1755d82b1a72372277bd95c8.zip
Warn on LDAP synchronization if the uid attribute is null/undefined
Diffstat (limited to 'src/main/java/com/gitblit/auth/LdapAuthProvider.java')
-rw-r--r--src/main/java/com/gitblit/auth/LdapAuthProvider.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/com/gitblit/auth/LdapAuthProvider.java b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
index 83f24669..a4d7bb05 100644
--- a/src/main/java/com/gitblit/auth/LdapAuthProvider.java
+++ b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
@@ -119,8 +119,12 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
final Map<String, UserModel> ldapUsers = new HashMap<String, UserModel>();
for (SearchResultEntry loggingInUser : result.getSearchEntries()) {
-
- final String username = loggingInUser.getAttribute(uidAttribute).getValue();
+ Attribute uid = loggingInUser.getAttribute(uidAttribute);
+ if (uid == null) {
+ logger.error("Can not synchronize with LDAP, missing \"{}\" attribute", uidAttribute);
+ continue;
+ }
+ final String username = uid.getValue();
logger.debug("LDAP synchronizing: " + username);
UserModel user = userManager.getUserModel(username);
@@ -295,13 +299,13 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
if (ldapConnection != null) {
try {
boolean alreadyAuthenticated = false;
-
+
String bindPattern = settings.getString(Keys.realm.ldap.bindpattern, "");
if (!StringUtils.isEmpty(bindPattern)) {
try {
String bindUser = StringUtils.replace(bindPattern, "${username}", escapeLDAPSearchFilter(simpleUsername));
ldapConnection.bind(bindUser, new String(password));
-
+
alreadyAuthenticated = true;
} catch (LDAPException e) {
return null;