aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes question on LDAP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "question on LDAP" Watch "question on LDAP" New topic
Author

question on LDAP

Xinyi Zhang
Ranch Hand

Joined: Apr 28, 2001
Posts: 42
Which class/method in JNDI can add entries into LDAP? Thanks.
[ April 15, 2002: Message edited by: Xinyi Zhang ]

Xinyi
kiran nori
Greenhorn

Joined: May 28, 2001
Posts: 12
javax.naming.InitialContext package has a method bind(name, object) used to add entried to a directory. here is the code that will do the needful.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import javax.naming.*;
import javax.naming.directory.*;
public class AddEntries
{

final String INITIAL_CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
Hashtable htbEnvironment = new Hashtable();
//DirContext to connect to Directory.
DirContext objDirCtx = null;
public AddEntries()
{
htbEnvironment.put( Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
htbEnvironment.put( Context.PROVIDER_URL, "ldap://10.10.10.10:389");
htbEnvironment.put( Context.SECURITY_PRINCIPAL, "userid" );
htbEnvironment.put( Context.SECURITY_CREDENTIALS,"password");
objDirCtx = new InitialDirContext(htbEnvironment);
}
public void addToDirectory()
{
// This is the object to be added to the directory. This class implements DirContext.
DirectoryObject objDirObject = new DirectoryObject();
try
{
objDirCtx.bind( "cn=object1,ou=blah,o=blah1", objDirObject );
System.out.println("Directory Object added successfully");
}
catch(Exception objExcep)
{
System.out.println("Got Exception While Adding");
}
}
}
[ April 17, 2002: Message edited by: kiran nori ]
 
 
subject: question on LDAP
 
Threads others viewed
What on earth could that recruiter mean?
LDAP
Weblogic is not getting started
Transaction management
Logged in windows username using ActiveXObject
IntelliJ Java IDE