Solved

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

Posted on 2011-03-23
2
1,304 Views
Last Modified: 2012-05-11
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
Comment
Question by:cano63
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 35202793
>                       ModificationItem[] mods = new ModificationItem[3];


change that to:


                      ModificationItem[] mods = new ModificationItem[1];
0
 
LVL 1

Author Comment

by:cano63
ID: 35202909
Ups Thanks a lot
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now