hi...
Iam using spring ldap to communicate with AD...I have some function to get data from AD as well as to post some data to AD...all my search functions by using ldapTemplate.search() is working very fine but ldapTemplate.bind() is not working....
I want to add new users to an existing group by using ldapTemplate.bind()...I am getting the values form a form and created a DirContextAdapter object by passing the DistinguishedName to it...and then I used DirContextAdapter's setter methods to set attribute values...but it is throwing javax.naming.NameAlreadyBoundException: [LDAP: error code 68 - 00002071: UpdErr: DSID-03050328, problem 6005 (ENTRY_EXISTS), data 0...
please help me to resolve this...
here my code
Configuration:
Java Code:<bean id="contextSource" class="org.springframework.ldap.core.support.LdapC ontextSource">
<property name="url" value="ldap\://xxx.xxx.123.10\:389" />
<property name="base" value="dc\=THINKDESK,dc\=IN" />
<property name="userDn" value="administrator@thinkdesk.in" />
<property name="password" value="password}" />
<property name="pooled" value="false"></property>
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate" >
<constructor-arg ref="contextSource" />
<property name="ignorePartialResultException" value="true"></property>
</bean>
Error stacktrace:public void addLdapUser(LdapUser lUser) {
DirContextAdapter luadapter=new DirContextAdapter(dn);
System.out.println("dn"+dn.toString());
luadapter.setAttributeValue("givenName",lUser.getF irst_name());
luadapter.setAttributeValue("sn", lUser.getLast_name());
luadapter.setAttributeValue("cn",lUser.getCn());
luadapter.setAttributeValue("mail", lUser.getEmail_id());
luadapter.setAttributeValue("description",lUser.ge tRole());
luadapter.setAttributeValue("company", lUser.getOrganization());
luadapter.setAttributeValue("l",lUser.getCity());
luadapter.setAttributeValue("st",lUser.getState()) ;
luadapter.setAttributeValue("co", lUser.getCountry());
luadapter.setAttributeValue("homePhone", lUser.getPhone());
luadapter.setAttributeValue("telephoneNumber", lUser.getMobile());
luadapter.setAttributeValue("userPrincipalName", lUser.getCn());
luadapter.setAttributeValue("sAMAccountName",lUser .getCn());
luadapter.setAttributeValue("displayName", lUser.getCn());
Object[]oc={"top","person","organizationalPerson","user"," inetOrgPerson"};
luadapter.setAttributeValues("objectClass", oc);
ldapTemplate.bind(luadapter);
}
Mar 24, 2012 8:50:01 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/ldap] threw exception [Request processing failed; nested exception is org.springframework.ldap.NameAlreadyBoundException : [LDAP: error code 68 - 00002071: UpdErr: DSID-03050328, problem 6005 (ENTRY_EXISTS), data 0
PLEASE HELP....


Reply With Quote