LDAP Mess
I found Novell's LDAP jar but I couldn't figure out the format to connect with(cn=Me,o=Domain,ou=Users <-- all that crap)
Anyways I had been able to connect using LDAPContext before so I figured I'd try that.
I found that LDAPConnection.modify is very similar to LdapContext.modifyAttributes
ex:
LDAPConnection.modify(String, LDAPModification);
LDAPModification takes (int, Attribute)
ctx.modifyAttributes(String,Int,Attributes);
basically the same thing..
so...
connect with:
String loginDN = args[0];
String password = args[1];
String ModifyDN = args[2];
String NewPassword = args[3];
try{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.ldap.version","3");
env.put("com.sun.jndi.ldap.connect.timeout", "10000");
env.put(Context.PROVIDER_URL, "ldap://apcs.net:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, loginDN);
env.put(Context.SECURITY_CREDENTIALS, password);
ctx = new InitialLdapContext(env, null);
System.out.println("x");
}
catch(NamingException ne){
System.err.println("ne: " + ne);
}
//so if LDAPConnection.modify works in theory with
lc.modify( ModifyDN, new LDAPModification(LDAPModification.REPLACE, attributePassword) );
//then shouldnt this work:
javax.naming.directory.Attributes ats = null;
ats.put("userPassword", NewPassword); //<-- * this is line 126
ctx.modifyAttributes(ModifyDN,LDAPModification.REPLACE,ats);
----
but no I get nullpointerexception at the *, ats.put("userPassword", NewPassword);
I get this in the console:
Exception in thread "main" java.lang.NullPointerException
at changePassword.main(changePassword.java:126)
x
"x" is printed at the end of the hashtable connection try
this shouldn't be this hard.

