peterbrews
Programmer
I am new to ldap .I need to write a method to be able to change password when the user request for it .What do i need to get this work done.I have no information about the ldap server which is on remote server of my client.
Currently i am using following code for authentication .
public String login(String userid, String password) {
StringBuffer result = new StringBuffer();
StringBuffer sb = new StringBuffer();
sb.append("uid="
sb.append(userid);
sb.append(",ou=zeesoftusers,"
sb.append("dc=zeesoft,"
sb.append("c=com"
String loginstr = sb.toString();
// Set-up Environment
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory"
environment.put(Context.PROVIDER_URL, "ldap://remotehostnameort"
environment.put(Context.SECURITY_PRINCIPAL,loginstr);
environment.put(Context.SECURITY_CREDENTIALS, password);
environment.put(Context.SECURITY_AUTHENTICATION, "simple"
try {
InitialDirContext root = new InitialDirContext(environment);
root.close();
result.append("SUCCESS"
} catch (NamingException ex) {
result.append("ERROR : " + ex);
logger.error(result.toString());
}
return result.toString();
}
any help is highly apprecaited.
thanks in advance
pete
Currently i am using following code for authentication .
public String login(String userid, String password) {
StringBuffer result = new StringBuffer();
StringBuffer sb = new StringBuffer();
sb.append("uid="
sb.append(userid);
sb.append(",ou=zeesoftusers,"
sb.append("dc=zeesoft,"
sb.append("c=com"
String loginstr = sb.toString();
// Set-up Environment
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory"
environment.put(Context.PROVIDER_URL, "ldap://remotehostnameort"
environment.put(Context.SECURITY_PRINCIPAL,loginstr);
environment.put(Context.SECURITY_CREDENTIALS, password);
environment.put(Context.SECURITY_AUTHENTICATION, "simple"
try {
InitialDirContext root = new InitialDirContext(environment);
root.close();
result.append("SUCCESS"
} catch (NamingException ex) {
result.append("ERROR : " + ex);
logger.error(result.toString());
}
return result.toString();
}
any help is highly apprecaited.
thanks in advance
pete