Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
| Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 8th, 2005, 02:49 PM
Registered User
Join Date: Oct 2004
Location: Porbandar, Gujarat, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default LDAP adding entries to the server :: how to??

Hello all,
               I have a code that adds the entries to the LDAP directory server and this code is in JAVA
But this code does compile but when i run it it gives Runtime error as
::::: Invalid credentials::::::

The server is running when the code is run. for this do i need to specify certain schema in the .CONF file or anything else
The server I am using is OpenLDAP for Windows and Netscape directory SDK for JAVA

 plz tell me about some another server available for LDAP support(free version) with JAVA (For Windows)
Plz tell me about the server and other information about LDAP Directory server so that i could find support for it easily

The code is as below::::::::::::::::::

import netscape.ldap.*;
import java.util.*;

public class Add {
    public static void main( String[] args )
        /* Specify the DN we're adding */
        //String nickname = rock.nickname;
        String dn = "uid=ac" ;

        /* Specify the attributes of the entry */
        String objectclass_values[] = { "top",
                                        "inetOrgPerson" };

        LDAPAttributeSet attrs = new LDAPAttributeSet();
        LDAPAttribute attr = new LDAPAttribute( "objectclass" );
        for( int i = 0; i < objectclass_values.length; i++ ) {
            attr.addValue( objectclass_values[i] );
        attrs.add( attr );

        attrs.add( new LDAPAttribute( "uid", "wbjensen" ) );

        /* Create an entry with this DN and these attributes */
        LDAPEntry myEntry = new LDAPEntry( dn, attrs );

        LDAPConnection ld = null;
        int status = -1;
        try {
            ld = new LDAPConnection();
            /* Connect to server */
            String MY_HOST = "localhost";
            int MY_PORT = 389;
            ld.connect( MY_HOST, MY_PORT );

            /* Authenticate to the server as directory manager */
            String MGR_DN = "dc=monarch,dc=com";
            String MGR_PW = "ali";
            ld.authenticate( MGR_DN, MGR_PW );
            System.out.println("Entry established");

            /* Now add the entry to the directory */
            ld.add( myEntry );
            System.out.println( "Entry added"  );
            System.out.println("Entry established1111");
        catch( LDAPException e ) {
            if ( e.getLDAPResultCode() == LDAPException.ENTRY_ALREADY_EXISTS )
                System.out.println( "Error: Entry already present" );
                System.out.println( "Error: " + e.toString()+"AA che error" );

        /* Done, so disconnect */
        if ( (ld != null) && ld.isConnected() ) {
            try {
            } catch ( LDAPException e ) {
                System.out.println( "Error: " + e.toString() );

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding SSL Certificate to Server.xml ZiGz BOOK: Professional Apache Tomcat 0 August 24th, 2007 08:56 PM
Problem adding a New View in Server Explorer taliesin VS.NET 2002/2003 2 March 21st, 2006 01:10 PM
LDAP bmains ASP.NET 1.0 and 1.1 Professional 0 May 26th, 2004 07:47 AM
Adding controls to Toolbox results in two entries DolphinBay VS.NET 2002/2003 4 April 2nd, 2004 07:56 PM
Adding a new record to a sql server DB morpheus VB How-To 6 August 6th, 2003 06:15 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.