Link to home
Start Free TrialLog in
Avatar of cano63
cano63

asked on

Ldap modify attribute with com.sun.jndi.ldap.LdapCtxFactory

Hello ,

I,m trying to update a attribute vale in my ldap, i,m using  com.sun.jndi.ldap.LdapCtxFactory class..

I,m able to get the users information but not update them,

I receive the following error

java.lang.NullPointerException
      at com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapCtx.java:1445)
      at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_modifyAttributes(ComponentDirContext.java:267)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:184)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(PartialCompositeDirContext.java:173)
      at javax.naming.directory.InitialDirContext.modifyAttributes(Unknown Source)
      at UpdateAttributes.main(UpdateAttributes.java:86)
DirContext ctx = new InitialDirContext(env);
			    String name = "uid=myID,cn=df,ou=customer,o=company";

			

			    // Specify the changes to make
			    ModificationItem[] mods = new ModificationItem[3];

			    // Replace the "mail" attribute with a new value
			    mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("type", "UUUU"));

		
			    
			    // Perform the requested modifications on the named object
			    ctx.modifyAttributes(name, mods);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cano63
cano63

ASKER

Ups Thanks a lot