Solved

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

Posted on 2011-03-23
2
1,313 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why cannot we forward request once the response is committed 2 42
diffSum example 4 36
javap bin 2 34
by zero exception 10 40
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

770 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