[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1430
  • Last Modified:

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

0
cano63
Asked:
cano63
1 Solution
 
objectsCommented:
>                       ModificationItem[] mods = new ModificationItem[3];


change that to:


                      ModificationItem[] mods = new ModificationItem[1];
0
 
cano63Author Commented:
Ups Thanks a lot
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now