Solved

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

Posted on 2011-03-23
2
1,359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

691 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