Fixed bug 414
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 21 Aug 2005 11:42:03 +0000 (11:42 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 21 Aug 2005 11:42:03 +0000 (11:42 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1810 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/aa/attrresolv/provider/JNDIDirectoryDataConnector.java

index 7294296..0ed9f74 100644 (file)
@@ -343,7 +343,17 @@ public class JNDIDirectoryDataConnector extends BaseDataConnector implements Dat
                        // attribute
                        if (context.getEnvironment().get(Context.INITIAL_CONTEXT_FACTORY)
                                        .equals("com.sun.jndi.ldap.LdapCtxFactory")) {
-                               BasicAttribute dn = new BasicAttribute("dn", result.getName() + "," + context.getNameInNamespace());
+                
+                // Check to see if the context was built with an empty base DN, if so don't try to append it
+                // otherwise we'll end up with a malformed DN (it'll contain a trailing comma).
+                String dnStr;
+                if(context.getNameInNamespace() == null || context.getNameInNamespace().length() ==0) {
+                    dnStr = result.getName();
+                }else {
+                    dnStr =  result.getName() + "," + context.getNameInNamespace();
+                }
+                
+                               BasicAttribute dn = new BasicAttribute("dn", dnStr);
                                attributes.put(dn);
                        }