java - Adding a user with a password in Active Directory LDAP -


this first time on stackoverflow, hope responses here. using windows active directory 2008 store new user java using spring-ldap api

my problem unable add user password. read somewhere in ad set password, should use unicodepwd attribute. source: http://geekswithblogs.net/lance/archive/2005/08/19/ldapauthenticationasp.aspx

public void insertcontact(contactdto contactdto) {     try{       attributes personattributes = new basicattributes();      basicattribute personbasicattribute = new basicattribute("objectclass");      personbasicattribute.add("person");      personbasicattribute.add("user");      personattributes.put(personbasicattribute);        personattributes.put("givenname", contactdto.getcommonname());       personattributes.put("cn", contactdto.getcommonname());       personattributes.put("sn", contactdto.getlastname());       personattributes.put("description", contactdto.getdescription());        personattributes.put("unicodepwd",           this.createunicodepassword(contactdto.getpassword()) );       personattributes.put("userprincipalname", contactdto.getuserloginname());       personattributes.put("samaccountname", contactdto.getsamaccountname());       personattributes.put("displayname", contactdto.getdisplayname());       //  personattributes.put( "pwdlastset", "0" );       //  personattributes.put( "lockouttime", "0" );        personattributes.put("useraccountcontrol", "544");        basicattribute roomattribute = new basicattribute("roomnumber");       for(string r : contactdto.getroomnumber())       {         roomattribute.add(r);       }        personattributes.put(roomattribute);         distinguishedname newcontactdn = new distinguishedname();       newcontactdn.add("cn", contactdto.getcommonname());        ldaptemplate.bind(newcontactdn, null, personattributes);     }  public byte[] createunicodepassword(string password){     return tounicodebytes(doublequotestring(password)); }  private byte[] tounicodebytes(string str){     byte[] unicodebytes = null;     try{         byte[] unicodebyteswithquotes = str.getbytes("unicode");         unicodebytes = new byte[unicodebyteswithquotes.length - 2];         system.arraycopy(unicodebyteswithquotes, 2, unicodebytes, 0,             unicodebyteswithquotes.length - 2);     } catch(unsupportedencodingexception e){         // should never happen.         e.printstacktrace();     }     return unicodebytes; }  private string doublequotestring(string str){     stringbuffer sb = new stringbuffer();     sb.append("\"");     sb.append(str);     sb.append("\"");     return sb.tostring(); } 

but given me error code 53

enter code here: org.springframework.ldap.uncategorizedldapexception: operation failed; nested exception javax.naming.operationnotsupportedexception: [ldap: error code 53 - 0000001f: svcerr: dsid-031a11e5, problem 5003 (will_not_perform), data 0 

i not know how set user password in ad. read set unicodepwd need ssl if required how can it. there alternative solve issue please me

yes, will_not_perform error ad telling you need use ssl connection set password.


to make ssl connection, need use url looks like: ldaps://your.ldap.server:636 (note "ldaps"). if certificate validation error, you'll need use "keytool" import ad server's certificate java keystore, java application recognizes certificate valid.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -