java - Remove user from Active Directory -


i have email distribution list "ctw dev". remove 1 user 'rakeshdw' activedirectory using java. please find below code.

its giving exception. user not getting removed. please suggest required changes. !

import java.io.bufferedreader; import java.io.filereader; import java.io.ioexception; import java.io.randomaccessfile; import java.nio.bytebuffer; import java.nio.channels.filechannel; import java.util.iterator; import java.util.properties; import java.util.hashset; import javax.naming.context; import javax.naming.namingenumeration; import javax.naming.namingexception; import javax.naming.directory.attribute; import javax.naming.directory.attributes; import javax.naming.directory.basicattribute; import javax.naming.directory.dircontext; import javax.naming.directory.initialdircontext; import javax.naming.directory.modificationitem; import javax.naming.directory.searchcontrols; import javax.naming.directory.searchresult; import java.util.properties;  import javax.naming.context; import javax.naming.directory.basicattribute; import javax.naming.directory.dircontext; import javax.naming.directory.initialdircontext; import javax.naming.directory.modificationitem;  public class deletefromadgroup {     private string adgroup,dn;     private dircontext ctx;     private string adminname = "intranet\\patilume";      deletefromadgroup(){         try{             this.adgroup  = "cn=ctw_dev";             this.dn= "ou=distributionlists,ou=messaging,dc=intranet,dc=infosysint,dc=com";             properties pr = new properties();             pr.setproperty(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory");             pr.setproperty(context.provider_url, "ldap://intranet.infosysint.com");             pr.setproperty(context.security_authentication,"simple");               pr.setproperty(context.security_credentials, "mypassword"); //its password             pr.setproperty(context.security_principal, this.adminname);                                   pr.setproperty(context.referral, "ignore");             this.ctx = new initialdircontext(pr);         }         catch(exception e){             system.out.println("in constructor..");         }     }     public static void main(string[] args) {         deletefromadgroup dadg=new deletefromadgroup();         dadg.deleteuser("ctw_dev","rakeshdw");     }     private void deleteuser(string adgroup, string username){         string groupname = "cn="+adgroup+",ou=distributionlists,ou=messaging,dc=intranet,dc=infosysint,dc=com";         try{              modificationitem mods[] = new modificationitem[1];             mods[0]= new modificationitem(dircontext.remove_attribute, new basicattribute("member", username));              //update group             ctx.modifyattributes(groupname,mods);             ctx.close();         }         catch(exception e){             system.out.println("exception while removing user dl");         }     }    } 

exception below:

javax.naming.operationnotsupportedexception: [ldap: error code 53 - 0000054f: svcerr: dsid-031a0fc0, problem 5003 (will_not_perform), data 0 

you need pass dn of user username attribute in deleteuser method. example, might cn=rakeshw,ou=people,dc=contoso,dc=com.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -