Connectionless LDAP and JNDI

Hi,
Please guide me how to connect or search on connectionless LDAP using JNDI. I wish to know how JNDI works over UDP while talking to connectionless LDAP.
Please reply as soon as possible it's urgent!!
Regards,
Abhijeet

Hi,
Please guide me how to connect or search on connectionless LDAP using JNDI. I wish to know how JNDI works over UDP while talking to connectionless LDAP.
Please reply as soon as possible it's urgent!!
Regards,
Abhijeet

Similar Messages

  • Noob to ldap and jndi

    Let' say you know the ldap url, port no, a valid userid / pwd , and the security authentication type. what other info would you need to successfully authenticate a user without binding to the ldap
    Any help is appreciated.
    Thanks
    Message was edited by:
    dumbmaster

    You can post this on the JNDI forum:
    http://forum.java.sun.com/forum.jspa?forumID=51

  • JNDI, LDAP, and Weblogic 6.0

    Hi-
    We are encountering an issue with JNDI and spurious "socket closed"
    exceptions. The players in our environment are Weblogic 6.0, Netscape
    Directory Server 4.1, (both running on Solaris 2.8) and JNDI as of JDK 1.3.
    We do JNDI lookups to connect to LDAP and most of the time everything works
    fine. Occasionally we get the following exception.
    java.lang.NullPointerException
    at com.sun.jndi.ldap.Connection.run(Connection.java:568)
    at java.lang.Thread.run(Thread.java:484)
    Exception encountered: Socket closed
    javax.naming.CommunicationException: Socket closed. Root exception is
    java.net.SocketException: Socket closed
    at java.net.SocketOutputStream.socketWrite(Native Method)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:72)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:130)
    at com.sun.jndi.ldap.Connection.writeRequest(Connection.java:210)
    at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:497)
    at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1720)
    at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1584)
    at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1509)
    at
    com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.ja
    va:371)
    at
    com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeD
    irContext.java:331)
    at
    com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeD
    irContext.java:316)
    at
    javax.naming.directory.InitialDirContext.search(InitialDirContext.java:241)
    at adpsis.posse.ldap.LDAPReader.find(LDAPReader.java:37)
    at adpsis.posse.prfpos.PreferencesEJB.getUserName(PreferencesEJB.java:589)
    at
    adpsis.posse.prfpos.PreferencesEJB.getColorAttributes(PreferencesEJB.java:39
    1)
    at
    adpsis.posse.prfpos.PreferencesEJB.getColorPreferences(PreferencesEJB.java:3
    02)
    at
    adpsis.posse.prfpos.PreferencesEJBImpl.getColorPreferences(PreferencesEJBImp
    l.java:250)
    at
    adpsis.posse.prfpos.PreferencesEJBEOImpl.getColorPreferences(PreferencesEJBE
    OImpl.java:287)
    at
    adpsis.posse.prfpos.PreferencesEJBEOImpl_WLSkel.invoke(PreferencesEJBEOImpl_
    WLSkel.java:116)
    at
    weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.java:373)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :128)
    at
    weblogic.rmi.internal.BasicServerAdapter.invoke(BasicServerAdapter.java:237)
    at
    weblogic.rmi.internal.BasicRequestHandler.handleRequest(BasicRequestHandler.
    java:118)
    at
    weblogic.rmi.internal.BasicRequestDispatcher.dispatch(BasicRequestDispatcher
    .java:115)
    at weblogic.rmi.internal.ServerRequest.sendOneWayRaw(ServerRequest.java:88)
    at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:108)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :247)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :225)
    at
    adpsis.posse.prfpos.PreferencesEJBEOImpl_WLStub.getColorPreferences(Preferen
    cesEJBEOImpl_WLStub.java:221)
    at adpsis.posse.transformer.CSSServlet.doPost(CSSServlet.java:86)
    at adpsis.posse.transformer.CSSServlet.doGet(CSSServlet.java:214)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:748)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :213)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:1265)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :1631)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The only way to recover is to restart the Weblogic server. The LDAP server
    appears to be running normally and continues to service other instances of
    Weblogic. No errors are logged in the LDAP server, the JNDI lookup that
    establishes the DirContext works fine on restart and is used multiple times
    with no issues until..poof..socket closed. I'm not certain which part is at
    issue, Weblogic, LDAP, or JNDI.
    Any ideas?
    Regards,
    Brett Schmoll
    ADP/SIS

    WLS 6.0 will be supported in the next release of WLCS, which is due in the
    spring.
    - Ginny
    "aamerG" <[email protected]> wrote in message
    news:3a5cb774$[email protected]..
    Hi everyone,
    we are starting a new development project and would like to use Weblogic
    6.0. How soon do you think there we be a version of WLCS which works with
    6.0.
    TIA

  • Problem with OpenLDAP and JNDI

    I'm having problem working with OpenLDAP and JNDI.
    First I have changed LDAP's slapd.conf file:
    suffix          "dc=antipodes,dc=com"
    rootdn          cn=Manager,dc=antipodes,dc=com
    directory     "C:/Program Files/OpenLDAP/data"
    rootpw          secret
    schemacheck offthan i used code below, to create root context:
    package test;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.naming.NameAlreadyBoundException;
    import javax.naming.directory.*;
    import java.util.*;
    public class MakeRoot {
         final static String ldapServerName = "localhost";
         final static String rootdn = "cn=Manager,dc=antipodes,dc=com";
         final static String rootpass = "secret";
         final static String rootContext = "dc=antipodes,dc=com";
         public static void main( String[] args ) {
                   // set up environment to access the server
                   Properties env = new Properties();
                   env.put( Context.INITIAL_CONTEXT_FACTORY,
                              "com.sun.jndi.ldap.LdapCtxFactory" );
                   env.put( Context.PROVIDER_URL, "ldap://" + ldapServerName + "/" );
                   env.put( Context.SECURITY_PRINCIPAL, rootdn );
                   env.put( Context.SECURITY_CREDENTIALS, rootpass );
                   try {
                             // obtain initial directory context using the environment
                             DirContext ctx = new InitialDirContext( env );
                             // now, create the root context, which is just a subcontext
                             // of this initial directory context.
                             ctx.createSubcontext( rootContext );
                   } catch ( NameAlreadyBoundException nabe ) {
                             System.err.println( rootContext + " has already been bound!" );
                   } catch ( Exception e ) {
                             System.err.println( e );
    }this worked fine, I could see that by using "LDAP Browser/Editor".
    and then I tried to create group with code:
    package test;
    import java.util.Hashtable;
    import javax.naming.*;
    import javax.naming.ldap.*;
    import javax.naming.directory.*;
    public class MakeGroup
         public static void main (String[] args)
              Hashtable env = new Hashtable();
              String adminName = "cn=Manager,dc=antipodes,dc=com";
              String adminPassword = "secret";
              String ldapURL = "ldap://127.0.0.1:389";
              String groupName = "CN=Evolution,OU=Research,DC=antipodes,DC=com";
              env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
              //set security credentials, note using simple cleartext authentication
              env.put(Context.SECURITY_AUTHENTICATION,"simple");
              env.put(Context.SECURITY_PRINCIPAL,adminName);
              env.put(Context.SECURITY_CREDENTIALS,adminPassword);
              //connect to my domain controller
              env.put(Context.PROVIDER_URL,ldapURL);
              try {
                   // Create the initial directory context
                   LdapContext ctx = new InitialLdapContext(env,null);
                   // Create attributes to be associated with the new group
                        Attributes attrs = new BasicAttributes(true);
                   attrs.put("objectClass","group");
                   attrs.put("samAccountName","Evolution");
                   attrs.put("cn","Evolution");
                   attrs.put("description","Evolutionary Theorists");
                   //group types from IAds.h
                   int ADS_GROUP_TYPE_GLOBAL_GROUP = 0x0002;
                   int ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x0004;
                   int ADS_GROUP_TYPE_LOCAL_GROUP = 0x0004;
                   int ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x0008;
                   int ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000;
                   attrs.put("groupType",Integer.toString(ADS_GROUP_TYPE_UNIVERSAL_GROUP + ADS_GROUP_TYPE_SECURITY_ENABLED));
                   // Create the context
                   Context result = ctx.createSubcontext(groupName, attrs);
                   System.out.println("Created group: " + groupName);
                   ctx.close();
              catch (NamingException e) {
                   System.err.println("Problem creating group: " + e);
    }got the error code: Problem creating group: javax.naming.directory.InvalidAttributeIdentifierException: [LDAP: error code 17 - groupType: attribute type undefined]; remaining name 'CN=Evolution,OU=Research,DC=antipodes,DC=com'
    I tried by creating organizational unit "ou=Research" from "LDAP Browser/Editor", and then running the same code -> same error.
    also I have tried code for adding users:
    package test;
    import java.util.Hashtable;
    import javax.naming.ldap.*;
    import javax.naming.directory.*;
    import javax.naming.*;
    import javax.net.ssl.*;
    import java.io.*;
    public class MakeUser
         public static void main (String[] args)
              Hashtable env = new Hashtable();
              String adminName = "cn=Manager,dc=antipodes,dc=com";
              String adminPassword = "secret";
              String userName = "cn=Albert Einstein,ou=Research,dc=antipodes,dc=com";
              String groupName = "cn=All Research,ou=Research,dc=antipodes,dc=com";
              env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
              //set security credentials, note using simple cleartext authentication
              env.put(Context.SECURITY_AUTHENTICATION,"simple");
              env.put(Context.SECURITY_PRINCIPAL,adminName);
              env.put(Context.SECURITY_CREDENTIALS,adminPassword);
              //connect to my domain controller
              env.put(Context.PROVIDER_URL, "ldap://127.0.0.1:389");
              try {
                   // Create the initial directory context
                   LdapContext ctx = new InitialLdapContext(env,null);
                   // Create attributes to be associated with the new user
                        Attributes attrs = new BasicAttributes(true);
                   //These are the mandatory attributes for a user object
                   //Note that Win2K3 will automagically create a random
                   //samAccountName if it is not present. (Win2K does not)
                   attrs.put("objectClass","user");
                        attrs.put("samAccountName","AlbertE");
                   attrs.put("cn","Albert Einstein");
                   //These are some optional (but useful) attributes
                   attrs.put("giveName","Albert");
                   attrs.put("sn","Einstein");
                   attrs.put("displayName","Albert Einstein");
                   attrs.put("description","Research Scientist");
                        attrs.put("userPrincipalName","[email protected]");
                        attrs.put("mail","[email protected]");
                   attrs.put("telephoneNumber","999 123 4567");
                   //some useful constants from lmaccess.h
                   int UF_ACCOUNTDISABLE = 0x0002;
                   int UF_PASSWD_NOTREQD = 0x0020;
                   int UF_PASSWD_CANT_CHANGE = 0x0040;
                   int UF_NORMAL_ACCOUNT = 0x0200;
                   int UF_DONT_EXPIRE_PASSWD = 0x10000;
                   int UF_PASSWORD_EXPIRED = 0x800000;
                   //Note that you need to create the user object before you can
                   //set the password. Therefore as the user is created with no
                   //password, user AccountControl must be set to the following
                   //otherwise the Win2K3 password filter will return error 53
                   //unwilling to perform.
                        attrs.put("userAccountControl",Integer.toString(UF_NORMAL_ACCOUNT + UF_PASSWD_NOTREQD + UF_PASSWORD_EXPIRED+ UF_ACCOUNTDISABLE));
                   // Create the context
                   Context result = ctx.createSubcontext(userName, attrs);
                   System.out.println("Created disabled account for: " + userName);
                   //now that we've created the user object, we can set the
                   //password and change the userAccountControl
                   //and because password can only be set using SSL/TLS
                   //lets use StartTLS
                   StartTlsResponse tls = (StartTlsResponse)ctx.extendedOperation(new StartTlsRequest());
                   tls.negotiate();
                   //set password is a ldap modfy operation
                   //and we'll update the userAccountControl
                   //enabling the acount and force the user to update ther password
                   //the first time they login
                   ModificationItem[] mods = new ModificationItem[2];
                   //Replace the "unicdodePwd" attribute with a new value
                   //Password must be both Unicode and a quoted string
                   String newQuotedPassword = "\"Password2000\"";
                   byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");
                   mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("unicodePwd", newUnicodePassword));
                   mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("userAccountControl",Integer.toString(UF_NORMAL_ACCOUNT + UF_PASSWORD_EXPIRED)));
                   // Perform the update
                   ctx.modifyAttributes(userName, mods);
                   System.out.println("Set password & updated userccountControl");
                   //now add the user to a group.
                        try     {
                             ModificationItem member[] = new ModificationItem[1];
                             member[0]= new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("member", userName));
                             ctx.modifyAttributes(groupName,member);
                             System.out.println("Added user to group: " + groupName);
                        catch (NamingException e) {
                              System.err.println("Problem adding user to group: " + e);
                   //Could have put tls.close()  prior to the group modification
                   //but it seems to screw up the connection  or context ?
                   tls.close();
                   ctx.close();
                   System.out.println("Successfully created User: " + userName);
              catch (NamingException e) {
                   System.err.println("Problem creating object: " + e);
              catch (IOException e) {
                   System.err.println("Problem creating object: " + e);               }
    }same error.
    I haven't done any chages to any schema manually.
    I know I'm missing something crucial but have no idea what. I have tried many other code from tutorials from net, but they are all very similar and throwing the same error I showed above.
    thanks in advance for help.

    I've solved this.
    The problem was that all codes were using classes from Microsoft Active Directory, and they are not supported in OpenLDAP (microsoft.schema in OpenLDAP is just for info). Due to this some fields are not the same in equivalent classes ("user" and "person").
    so partial code for creating user in root would be:
    import java.util.Hashtable;
    import javax.naming.ldap.*;
    import javax.naming.directory.*;
    import javax.naming.*;
    import javax.net.ssl.*;
    import java.io.*;
    public class MakeUser
         public static void main (String[] args)
              Hashtable env = new Hashtable();
              String adminName = "cn=Manager,dc=antipodes,dc=com";
              String adminPassword = "secret";
              String userName = "cn=Albert Einstein,ou=newgroup,dc=antipodes,dc=com";
              env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
              //set security credentials, note using simple cleartext authentication
              env.put(Context.SECURITY_AUTHENTICATION,"simple");
              env.put(Context.SECURITY_PRINCIPAL,adminName);
              env.put(Context.SECURITY_CREDENTIALS,adminPassword);
              //connect to my domain controller
              env.put(Context.PROVIDER_URL, "ldap://127.0.0.1:389");
              try {
                   // Create the initial directory context
                   LdapContext ctx = new InitialLdapContext(env,null);
                   // Create attributes to be associated with the new user
                        Attributes attrs = new BasicAttributes(true);
                                  attrs.put("objectClass","user");
                   attrs.put("cn","Albert Einstein");
                   attrs.put("userPassword","Nale");
                   attrs.put("sn","Einstein");
                   attrs.put("description","Research Scientist");
                   attrs.put("telephoneNumber","999 123 4567");
                   // Create the context
                   Context result = ctx.createSubcontext(userName, attrs);
                   System.out.println("Successfully created User: " + userName);
              catch (NamingException e) {
                   System.err.println("Problem creating object: " + e);
    }hope this will help anyone.

  • Connecting to LDAP using JNDI

    I am trying to connect to LDAP to check an entry.
    Following is the servlet code I am using.
    /* @author
    This class is establish to connect the LDAP user directory and get the user attributes
    (SSO_USERID, USER_ID, USER_NAME and USER_MAIL) from the LDAP User directory. */
    import java.io.*;
    import java.util.Enumeration;
    import java.util.*;
    import javax.naming.*;
    import javax.naming.directory.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.lang.*;
    public class LDAPSearch extends HttpServlet
              //public static String MY_FILTER1 = "";
              public static String MY_FILTER2 = "";
              public static String INITCTX="com.sun.jndi.ldap.LdapCtxFactory";
              public static String MY_HOST="ldap://3.245.97.5:389";
              public static String MY_SEARCHBASE="o=ge.com";
              public void doGet (HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
                   doPost(request,response);
              public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
                        PrintWriter out=response.getWriter();
                        try
                             HttpSession session = request.getSession(true);
                             String str_user=(String)request.getParameter("txtSearch");
                             //out.println(str_user);
                             String ssoid = request.getParameter("ssoid");
                             //String str_parname = (String)request.getParameter("selNames");
                             System.out.println("str_user"+str_user);
                             String firstName="";
                             String lastName="";
                             String str_complete = "";
                             //char data[]={str_user,',');
                             StringTokenizer st=new StringTokenizer(str_user,",");
                             int stCount = st.countTokens();
                             if(stCount == 1)
                                  firstName = st.nextToken();
                                  System.out.println("firstName "+firstName);
                             else
                                  while(st.hasMoreTokens())
                                       lastName=st.nextToken();
                                       firstName=st.nextToken();
                                       //out.println("firstName "+firstName);
                                       //out.println("lastName "+lastName);
                        if(ssoid == null)
                             if(stCount == 1)
                                       MY_FILTER2 = "(givenName="+firstName+")";
                                       System.out.println("MY_FILTER2"+MY_FILTER2);
                                  else
                                  MY_FILTER2 = "(&(givenName="+firstName+")(sn="+lastName+"))";
                                  //out.println("MY_FILTER2"+MY_FILTER2);
                             else
                                  MY_FILTER2 = "(cn="+ssoid+")";
                             out.println("<html>");
                             out.println("<head><title>SSO User lookup / Search</title></head>");
                             out.println("<script language=\"javascript\">");
                             out.println("function back(){");
                             out.println("document.frmLDAPSearch.ssoid.value = document.frmLDAPSearch.selNames[document.frmLDAPSearch.selNames.selectedIndex].value;");
                             out.println("document.frmLDAPSearch.target='ERPUser';");
                             out.println("document.frmLDAPSearch.submit();");
                             out.println("window.close();");
                             out.println("}");
                             out.println("</script>");
                             out.println("<BODY BGCOLOR='#FFFFFF'><table border='0' align = 'center' width = '100%' >");
                             out.println("<form name=\"frmLDAPSearch\" method=\"get\" action='/servlet/LDAPSearch'>");
                             String str_ssoid = "";
                             String str_uid="";
                             String str_mailid = "";
                             String str_name = "";
                             String last = "";
                             String str_fullname = "";
                             //out.println("Origninal name "+str_parname);
                             Hashtable env=new Hashtable();
                             env.put(Context.INITIAL_CONTEXT_FACTORY,INITCTX);
                             env.put(Context.PROVIDER_URL,MY_HOST);
                             DirContext ctx=new InitialDirContext(env);
                             SearchControls constraints=new SearchControls();
                             constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
                             Vector vOut = new Vector();
                             NamingEnumeration results=ctx.search(MY_SEARCHBASE,MY_FILTER2,constraints);
                             while(results !=null && results.hasMore())
                                       SearchResult sr=(SearchResult)results.next();
                                       String dn=sr.getName() +"," +MY_SEARCHBASE;
                                       Attributes attrs=sr.getAttributes();
                                       for(NamingEnumeration ne=attrs.getAll();ne.hasMoreElements();)
                                            Attribute attr=(Attribute)ne.next();
                                            String attrID=attr.getID();
                                            if(attrID.equals("mail"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"red\">");
                                                 str_mailid = (String)vals.nextElement();
                                            if(attrID.equals("gessouid"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"red\">");
                                                 str_ssoid = (String)vals.nextElement();
                                            if(attrID.equals("uid"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"red\">");
                                                 str_uid = (String)vals.nextElement();
                                            if(attrID.equals("givenname"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"red\">");
                                                 str_name = (String)vals.nextElement();
                                            for(Enumeration vals=attr.getAll();vals.hasMoreElements();)
                                                 vals.nextElement();
                                            if(attrID.equals("sn"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"green\">");
                                                 last = (String)vals.nextElement();
                                            if(attrID.equals("cn"))
                                                 Enumeration vals=attr.getAll();
                                                 out.println("<font color=\"green\">");
                                                 str_complete = (String)vals.nextElement();
                                                 System.out.println("str_complete "+str_complete);
                                            //if(lastName.equalsIgnoreCase(last) || (stCount == 1))
                                                 if(attrID.equals("cn"))
                                                      int i=0;
                                                      Enumeration vals=attr.getAll();
                                                      out.println("<font color=\"red\">");
                                                      str_fullname = (String)vals.nextElement();
                                                      vOut.addElement(new String(str_fullname));
    //                                   } //END OF IF LASTNAME EQUALS
                                  }//END OF FOR LOOP
                             }//END OF WHILE"#FF00FF"
                                       out.println("<form><body bgcolor='#00FFFF' >");
                                       out.println("<div align=\"CENTER\" >");
                                       out.println("<input type=hidden name=txtSearch value='"+str_user+"'>");
                                       System.out.println("LDAP SEARCH: txtSearch="+str_user);
                                       out.println("<input type=hidden name=ssoid value=''>");
                                       String multiple=request.getParameter("multiple");
                                       if (multiple!=null)
                                       if (multiple.equalsIgnoreCase("true"))
                                                 out.println("<br>");
                                                 out.println("<table align=\"center\" >");
                                                 out.println("<tr><td align=\"center\"><select name='selNames' size=3>");
                                                 out.println("<option value='"+vOut.elementAt(0).toString()+"' selected>");
                                                 out.println(vOut.elementAt(0).toString());
                                                 out.println("</option>");
                                                 for(int i=1;i<vOut.size();i++)
                                                      out.println("<option value='"+vOut.elementAt(i).toString()+"'>");
                                                      out.println(vOut.elementAt(i).toString());
                                                      out.println("</option>");
                                                      System.out.println("i"+i);
                                                 out.println("</select><td></tr>");
                                                 out.println("<tr bgcolor='#00638C'><td align=\"center\"><input type=\"button\" value=\"populate\" onclick=\"back();\"></td>");
                                                 out.println("</td></tr></table>");
                                                 out.println("</div></body</form>");
                                       else{
                                       if(vOut.size()==1)
                                            session.putValue("SSOID",str_ssoid);
                                            session.putValue("USERID",str_uid);
                                            session.putValue("EMAIL",str_mailid);
                                            session.putValue("NAME",str_complete);
                                            response.sendRedirect("/servlet/Protected/InvtAddUser?txtSearch="+str_user);
                                       else if(vOut.size()==0)
                                            out.println("<SCRIPT SRC='/InvTrack/InvTrack.js'>");
                                            out.println("</SCRIPT>");
                                            out.println("<BODY BGCOLOR='#FFFFFF' onUnload='winLogout()' >");
                                            out.println("<table border='0' cellpadding='0' cellspacing='0' width='100%' >");
                                            out.println("<tr><td><img src='/ge.gif'alt='GE Medical Systems'></td>");
                                            out.println("<td><img src='/gr_toprighthd.jpg' alt='GE Medical Systems'></td></tr></table>");
                                            out.println("<BR><BR><BR>");
                                            out.println("<P ALIGN='CENTER'><FONT COLOR='#333399' SIZE='4'><B><FONT FACE='ARIAL, HELVETICA, SANS-SERIF'> <FONT COLOR='#800000'>Sorry!</FONT></FONT></B></FONT></p>");
                                            out.println("<P ALIGN='CENTER'><FONT COLOR='#333399' SIZE='4'><FONT FACE='ARIAL, HELVETICA, SANS-SERIF'> either you have typed incorrectly <br>or user has not registered a GEMS Intranet Single Sign On Userid </FONT></p>");
                                            out.println("<P ALIGN='CENTER'><FONT COLOR='#333399' SIZE='4'><FONT FACE='ARIAL, HELVETICA, SANS-SERIF'><A HREF=\"Javascript:history.back();\">Back</A></FONT></P>");
                                            out.println("</body>");
                                  else
                                            response.sendRedirect("/servlet/Protected/InvtAddUser?multiple=true&txtSearch="+str_user);
                                       out.println("</form></body></html>");
                        catch(Exception e)
                             out.println(e.toString());
    I am getting the followung exception::
    [03/Feb/2002:16:46:29] failure ( 481): Internal error: exception thrown from the servlet service function (uri=/servlet/LDAPSearch): java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/ctx/ComponentDirContext, Stack: java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/ctx/ComponentDirContext
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java, Compiled Code)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java, Compiled Code)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java, Compiled Code)
         at java.net.URLClassLoader.access$1(URLClassLoader.java, Compiled Code)
         at java.net.URLClassLoader$1.run(URLClassLoader.java, Compiled Code)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java, Compiled Code)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java, Compiled Code)
         at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
         at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:77)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
         at javax.naming.InitialContext.init(InitialContext.java:218)
         at javax.naming.InitialContext.<init>(InitialContext.java:194)
         at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:87)
         at LDAPSearch.doPost(LDAPSearch.java, Compiled Code)
         at LDAPSearch.doGet(LDAPSearch.java:34)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:701)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:826)
         at com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:462)
    I have included ldap.jar and jndi.jar in the CLASSPATH for IPlanetWebServer that I am using.
    Please get back.

    java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/ctx/ComponentDirContext
    Seems pretty straight forward to me. That class isn't there, and it wants it. Check all your classpaths to verify that class is in them. I bet it's not. Also, a side note. You see where it says "compiled code" in the stack trace instead of a line number. You can force the VM to interpret to give you a line number by setting your JAVA_COMPILER variable to "none" Or depending on the version of the VM you are using you can supply the -Xint switch which forces interpretation.

  • Need help in retrieving attributes from LDAP using JNDI

    I am trying to retrieve attributes from LDAP using JNDI, but I'm getting the following error when I try to run my Java program.
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/naming/NamingException
    I have all the jar files in my classpath: j2ee.jar, fscontext.jar and providerutil.jar. The interesting thing is that it gets compiled just fine but gives an error at run-time.
    Could anyone tell me why I'm getting this error? Thanks!
    Here's my code:
    import javax.naming.*;
    import javax.naming.directory.*;
    import java.util.*;
    import java.io.*;
    class Getattr {
    public static void main(String[] args) {     
    // Identify service provider to use     
    Hashtable env = new Hashtable(11);     
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");      
    // user     info
    String userName = "username";     
    String password = "password";          
    // LDAP server specific information     
    String host = "ldaphostname";     
    String port = "portnumber";     
    String basedn = "o=organization,c=country";     
    String userdn = "cn=" + userName + "," + basedn;          
    env.put(Context.PROVIDER_URL, "ldap://" + host + ":" + port + "/" + basedn);     
    env.put(Context.SECURITY_PRINCIPAL, userdn);     
    env.put(Context.SECURITY_CREDENTIALS, password);     
    try {          
    System.setErr(new PrintStream(new FileOutputStream(new File("data.txt"))));     
    // Create the initial directory context     
    DirContext ctx = new InitialDirContext(env);          
    // Ask for all attributes of the object      
    Attributes attrs = ctx.getAttributes("cn=" + userName);          
    NamingEnumeration ne = attrs.getAll();                    
    while(ne.hasMore()){                         
    Attribute attr = (Attribute) ne.next();                                   
    if(attr.size() > 1){               
    for(Enumeration e = attr.getAll(); e.hasMoreElements() ;) {                                       
    System.err.println(attr.getID() + ": " + e.nextElement());                     
    } else {
         System.err.println(attr.getID() + ": " + attr.get());
    // Close the context when we're done     
    ctx.close();     
    } catch(javax.naming.NamingException ne) {
         System.err.println("Naming Exception: " + ne);     
    } catch(IOException ioe) {
         System.err.println("IO Exception: " + ioe);     

    That doesn't work either. It seems its not finding the NamingException class in any of the jar files. I don't know why? Any clues?

  • Problem with creating Connection pool and JNDI, driver is not detected

    Hi,
    I have an issue with creating Connection Pool and JNDI.
    I'm using:
    - JDK 1.6
    - OS: Linux(ubuntu 8.10)
    - Netbeans IDE 6.5.1
    - Java EE 5.0
    - Apache Tomcat 6.0.18 Its lib directory contains all necessary jar files for Oracle database driver
    - Oracle 11g Enterprise
    My problem is that the Oracle database driver is not detected when I want to create a pool (it works pretty well and is detected without any problem when I create ordinary connection by DriverManager)
    Therefore after running:
    InitialContext ic = new InitialContext();
    Context context = (Context)ic.lookup("java:comp/env");
    DataSource dataSource = (DataSource)context.lookup("jdbc/oracle11g");
    Connection connection = dataSource.getConnection();and right after dataSource.getConnection() I have the following exception:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at servlets.Servlet1.doPost(Servlet1.java:47)
    at servlets.Servlet1.doGet(Servlet1.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
    ... 17 more
    My application context file (context.xml) is:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/WebApplication3">
      <Resource auth="Container"
                      driverClassName="oracle.jdbc.OracleDriver"
                      maxActive="8"
                      maxIdle="4"
                      name="jdbc/oracle11g"
                      username="scott"
                      password="tiger"
                      type="javax.sql.DataSource"
                      url="jdbc:oracle:thin:@localhost:1521:database01" />
    </Context>and my web.xml is:
        <resource-ref>
            <description>Oracle Datasource example</description>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
    ...I found similar threads in different forums including sun, such as
    http://forums.sun.com/thread.jspa?threadID=567630&start=0&tstart=0
    http://forums.sun.com/thread.jspa?threadID=639243&tstart=0
    http://forums.sun.com/thread.jspa?threadID=5312178&tstart=0
    , but no solution.
    As many suggest, I also tried to put context directly in the server.xml (instead of my application context) and referencing it by <ResourceLink /> inside my application context but it didn't work and instead it gave me the following message:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '   ' for connect URL 'null'
    Has anyone succeeded in creating a connection pool with JNDI by using Tomcat 6 or higher ? If yes, could kindly explain about the applied method.
    Regards,

    Hello again,
    Finally I managed to run my application also with Tomcat 6.0.18. There was only two lines that had to be modified
    in the context.xml file (the context of my application project and not server's)
    Instead of writing
    <Context antiJARLocking="true" path="/WebApplication2">
        type="javax.sql.DataSource"
        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    </Context>we had to write:
    <Context antiJARLocking="true" path="/WebApplication2">
        type="oracle.jdbc.pool.OracleDataSource"
        factory="oracle.jdbc.pool.OracleDataSourceFactory"
    </Context>- No modification was needed to be done at server level (niether server.xml nor server context.xml)
    - I just added the ojdbc6.jar in $CATALINA_HOME/lib (I didn't even need to add it in WEB-INF/lib of my project)
    - The servlet used to do the test was the same that I presented in my precedent post.
    For those who have encountered my problem and are interested in the format of the web.xml and context.xml
    with Tomcat 6.0, you can find them below:
    Oracle server: Oracle 11g Enterprise
    Tomcat server version: 6.0.18
    Oracle driver: ojdbc.jar
    IDE: Netbeans 6.5.1
    The context.xml file of the web application
    <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/WebApplication2">
        <Resource name="jdbc/oracle11g"
                  type="oracle.jdbc.pool.OracleDataSource"
                  factory="oracle.jdbc.pool.OracleDataSourceFactory"
                  url="jdbc:oracle:thin:@localhost:1521:database01"
                  driverClassName="oracle.jdbc.OracleDriver"
                  userName="scott"
                  password="tiger"
                  auth="Container"
                  maxActive="100"
                  maxIdle="30"
                  maxWait="10000"
                  logAbandoned="true"
                  removeAbandoned="true"
                  removeAbandonedTimeout="60" />
    </Context>The web.xml of my web application
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <resource-ref>
            <description>Oracle Database 11g DataSource</description>
            <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
            <res-auth>Container</res-auth>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
        </resource-ref>
        <servlet>
            <servlet-name>Servlet1</servlet-name>
            <servlet-class>servlets.Servlet1</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Servlet1</servlet-name>
            <url-pattern>/Servlet1</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>Ok, now I'm happy as the original problem is completely solved
    Regards

  • OD, LDAP and DNS

    I am new to LDAP and I believe I have everything setup correctly on the server (everything under Open Directory in SA says "Running", logs don't show any errors). However, I can not access the LDAP server from a client machine using Directory Access. I suspect that client machines still can not "see" my LDAP server.
    I believe the issue may be with DNS and I am trying to understand the interaction between DNS and OD, etc. First off, I do not have DNS turned on for my Mac OS X Server since my ISP has always hosted our DNS. Is this a problem? Do I need DNS activated on the same server that I am running this LDAP server? I have tried entering the IP and DNS name on the client server using Directory Access and neither worked.

    The requirement is that references using your server's Fully Qualified Domain Name look up to its IP Address and its IP Address looks up to its Fully Qualified Domain Name. If your ISP does that for you, and does it correctly, Merry Christmas!
    All others must set up their own tiny DNS service to do the lookups. If you are behind an NAT firewall, you can Make Up whatever names you like and look them up locally, because they are invisible from the Internet.
    Remember that each workstation must have the address of the DNS available to it. It needs to be configured in the TCP/IP setup or dispensed via DHCP. If you use your own DNS (highly recommended) you must also dispense or configure the next upstream DNS (your ISP's DNS Address).
    "An Open Directory master requires properly configured DNS so it can provide single sign-on Kerberos authentication.
    Make sure DNS service is configured to resolve fully qualified DNS names and provide corresponding reverse lookups.
    DNS must resolve the fully qualified DNS name and provide reverse lookups for the Open Directory master server, all replica servers, and other servers that are members of the Kerberos realm.
    You can use the Lookup pane of Network Utility (in /Applications/Utilities/) to do a DNS lookup of a server's DNS name and a reverse lookup of the server's IP address.
    For instructions on setting up DNS service, browse Network Services Overview."
    -- from Server Admin 10.4 Help: Kerberos is Stopped on an Open Directory Master or Replica
    Message was edited by: Grant Bennet-Alder

  • 10.6.6 Server Combo Update Crashes LDAP and Kerberos Services

    Just updated apple server from 10.6.4 to 10.6.6 with combo server overnight.
    Everything was working fine under 10.6.4
    All users can no longer authenticate to server via mail or ldap logins
    LDAP and Kerberos Services stopped.
    Will downgrade from an open directory master to standalone then back to master again and post status...

    I think there is something with LDAP on 10.6.6
    I was forced to make clean install in combo from 10.6.0 to 10.6.6 and today LDAP crashed.
    It seems to be an issue on ldap ACL.
    Message was edited by: Xalio

  • How to get the naming attribute of an LDAP using JNDI.?

    Hi,
    How do we fetch the naming attribute of a LDAP using JNDI. Is this possible using JNDI..?
    By default, every LDAP has been set with a naming attribute such as 'uid' or 'cn'. This could be changed according to business needs.
    How to determine this using JNDI.
    Regards,
    Barani

    Are you trying to call the portlet Customization form directly from the browser?

  • MAC OS and LDAP and Samba Server

    How can I make my Mac OS authenticate against LDAP and automatically map shared by a Samba server folders? (samba domain)? The idea is that any person who is registered in the database of LDAP can log into any Mac machine and automatically access the folders stored on the Samba server.

    Are you using TopLink 11g or TopLink Essentials?
    You seem to be wanting to use TopLink 11g, but you have the provider set to Essentials in your persistence.xml.
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    Change this to,
    <provider>oracle.toplink.PersistenceProvider</provider>
    The sessions-xml properties are only supported with TopLink 11g.
    Note that currently in 11g when using a sessions-xml it must contain a project xml that completely defines the mappings. It will not merge with annotations nor defaults.

  • LDAP and OID

    FYI: I am new to Oracle (<1 month), and new to APEX (<3 weeks) so forgive me if I am asking the obvious.
    I would like to have APEX authenticate against LDAP (active directory), and went about trying to set that up. Got all AD settings from our sys admin, and then tried them in the LDAP test tool. I kept getting " Authentication failed!" no matter what I did. Due to the detailed nature of that error message, I started trying to track down every possible avenue so I talked to one of our DBA's about DBMS_LDAP.SIMPLE_BIND_S. The answer I got back was that we don't have access to it because it is part of OIN which we would have to pay outrageous amounts of money for if we wanted to use it. Not likely to happen, so I was hoping that there was another way to authenticate APEX via LDAP.
    Any suggestions would be most helpful.

    John - DBMS_LDAP is not part of OID so you can use it as part of your existing database product installation. Search this forum for LDAP and AD and you'll find lots of discussions about what you are trying to do.
    Also, just to clarify, you're not trying to authenticate Application Express using AD, you'll be authenticating users to your application (essentially a PL/SQL application in the database) using account information stored in AD. The authentication code that gets executed will belong to your application.
    Scott

  • LDAP and SAP integration

    Hi,
    As a part of a project requirement, we are trying to integrate Solution manager with LDAP (Lightweight Directory Access Protocol).
    Using the directory service, we are trying to synchronize the CUA (Central user administration within Solution manager) with Active directory of LDAP so that we can maintain the User data centrally from a single point in LDAP.
    Problem description:
    Currently, Client has implemented the LDAP and CUA integration and when a new user is added in LDAP, it is automatically getting copied in all SAP systems and at real time, when the useru2019s u201CLASTNAMEu201D field is updated in LDAP, it is automatically getting synchronized in all SAP systems.
    But, If any attribute other than u201CLASTNAMEu201D is changed (i.e. The expiry /validity date of the User in LDAP, GLTGB in SAP), then the field value is not getting synchronized in the SAP Central User Adm.
    Our Findings:
    We have checked the configurations and imported mappings in SAP Solution Manager and everything looks fine. We have debugged the standard program RSLDAPSYNC_USER extensively and found out that an RFC call to function module LDAPRFC_SEARCH is not returning the expected values.
    Thanks
    Deb

    Hi Deb,
    It would be really nice if you can elaborate on the configurations that need to be done as part of this integration. I hope, you have been successfull by now.
    Actually, I too need to perform the same as part of a project.
    Thanks in advance.

  • Implementing JMS-based EDN and JNDI-based EDN

    I´m implementing a composite with two kinds of events JMS and JNDI and I saw in the configuration for JMS-base I must remove the EDN-DB JNDI sources to use EDN-JMS data sources. My doubt is, does my composite will work with that two kinds of events?
    All the best,
    Pierre

    This is a functional desire that has come up on some of our projects too but is not directly supported by EDN. We have discussed the idea of EDN proxies (either as SOA Composites or as PL/SQL EDN subscribers). These proxies (presumably always active/deployed) would subscribe to EDN and provide a persistent buffer for the application. This is essentially implementing a persistence queue for each subscriber, but we wish to avoid statically configuring an AQ or JMS queue destination for each and every app subscription case and perhaps use some shared-but-keyed persistence design (e.g. database table).
    Architecturally, this starts to hit on the ever evasive and controversial question of what is an "Event" versus what is a "Message". i.e. can you afford to sometimes miss the former but not the latter?
    -Todd

  • Hello, Identity manager fail to add entries in the LDAP and database table

    Hello,
    Well I installed identity manager 7 in a windows 2003 advanced server.
    I I appended an NT server resource, a Mysql table, a solaris server resource and an ldap server resource.
    I created the roles for these resources and then I assigned them to an account that I created for testing purposes.
    After the aprooval, in the solaris machine, the user has been added in the user database but no home directory has been created as I didn't set the apropriate flag to true.
    I the windows resource everything worked very smooth and with no problem.
    In the ldap and mysql table resources I recieved a failure having error message null. and from a sniffing that I did for investigation I never saw a sigle packed arrive to the mysql server or to the directory server from the idm server.
    Any ideas or suggestions on what to do ?

    Well the problem with the directory server just solved.
    But the problem with mysql remains.
    The first thing that I do when I add a resource is to test the connection.
    The problem with the LDAP is that the dn was not present in the directory server. They gave me an ou that didn't exist.

Maybe you are looking for