Commit d0d5e6a2 authored by wannes's avatar wannes
Browse files

Use DN instead of RDN

parent 87e99671
......@@ -111,7 +111,7 @@ public class LDAP {
if (result == 1) return true;
LDAPConnection connection = new LDAPConnection(socketFactory, host.get(), Integer.parseInt(Config.get("ldap/port", "636")));
BindResult bind = connection.bind(new RDN(dn).toString(), password);
BindResult bind = connection.bind(new DN(dn).toString(), password);
boolean success = bind.getResultCode().equals(ResultCode.SUCCESS);
connection.close();
return success;
......
......@@ -18,6 +18,7 @@
package be.neutrinet.ispng.vpn;
import be.neutrinet.ispng.security.OwnedEntity;
import com.unboundid.ldap.sdk.DN;
import com.unboundid.ldap.sdk.persist.LDAPField;
import com.unboundid.ldap.sdk.persist.LDAPGetter;
import com.unboundid.ldap.sdk.persist.LDAPObject;
......@@ -75,7 +76,14 @@ public class User implements OwnedEntity {
}
public String getDN() {
return "mail=" + email + "," + Users.usersDN();
String dn = "mail=" + email + "," + Users.usersDN();
try {
return new DN(dn).toString();
} catch (Exception ex) {
Logger.getLogger(getClass()).error("Malformed DN " + dn, ex);
}
return "";
}
public void setPassword(String password) {
......
......@@ -99,7 +99,7 @@ public class Users {
public static User get(String email) {
try {
return persister.get(new RDN("mail=" + email + "," + usersDN()).toString(), LDAP.connection());
return persister.get(new DN("mail=" + email + "," + usersDN()).toString(), LDAP.connection());
} catch (LDAPException ex) {
Logger.getLogger(Users.class).error("Failed to get user", ex);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment