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.
Similar Messages
-
Problem in connecting to LDAP using JNDI please HELP ME!!!!!!
hi
i am trying to connect to the LDAp using the JNDi
and i am getting the following error i was unable to solve it
here i am posting my sample slapd.cof file as well as my source program and the error
# ldbm database definitions
database ldbm
#suffix "dc=stooges,dc=org"
suffix "o=sgstest"
rootdn "cn=sgstestAdmin,o=sgstest"
rootpw secret3
directory /var/lib/ldap/sgstest
defaultaccess read
schemacheck off
lastmod onand my program source code is
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 test{
final static String ldapServerName = "localhost";
final static String rootdn = "cn=SgstestAdmin,o=sgstest";
final static String rootpass = "secret3";
final static String rootContext = "o=sgstest";
public static void main(String[] args) {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.PROVIDER_URL,"ldap://"+ldapServerName+"/"+rootContext);
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.
Integer i = new Integer( 28420 );
System.out.println("Adding " + i + " to directory..." );
ctx.bind("cn=myRandomInt",i);
i = new Integer( 98765 );
System.out.println( "i is now: " + i );
} catch (NameAlreadyBoundException nabe) {
System.err.println(rootContext + " has already been bound!" );
} catch ( Exception e ) {
System.err.println( e );
1,17 Top
}the error which i am getting is
Adding 28420 to directory...
javax.naming.directory.InvalidAttributeIdentifierException:
[LDAP: error code 17 - javaSerializedData: attribute type undefined]; remaining name 'cn=myRandomInt'any help would be appreciatedHi,
just one question: is your LDAP server configured to support the JAVA object classes and attributes like javaSerializedData? E.g., if you're using openldap, you have to add a line to the slapd.conf configuration file to import the java definitions. -
Hi all:
I want to connect to a LDAP use SSL, my code is like following.
Hashtable env = new Hashtable();
String ADuid = "user";
String ADpwd = "pwd";
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,ADuid);
env.put(Context.SECURITY_CREDENTIALS,ADpwd);
env.put(Context.SECURITY_PROTOCOL,"ssl");
env.put(Context.PROVIDER_URL, "ldaps://server address:636");
try {
System.setProperty("javax.net.ssl.trustStore","truststore");
System.setProperty("javax.net.ssl.trustStorePassword", 123456");
// Create the initial directory context
DirContext ctx = new InitialDirContext(env);
}catch(Exception ex){
wdComponentAPI.getComponent().getMessageManager().reportException(store + ex.toString(),false);
These code is tested sucessful on java application. But can't work on webdynpro program, it reports an Exception "javax.naming.CommunicationException: simple bind failed Root exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found] "
I've tryed to put the truststore on different DIR, but still not work. Does the method System.setProperty available on Web server? How to implement SSL certification?Hi Wayne Lou,
I have same issue in connecting LDAP over SSL port 636 in Web Dynpro JAVA code.
could you please share your solution code or guide me to solve my issue.
Regards,
Lakshmi Narayana Kodavati, -
Errror during SSL connection with LDAP using JNDI APIs
Hello,
I have established a client and server certificates cert.arm for LDAP server and client. On client i have created a client.kdb file and on server server.kdb file both containing cert.arm. whwn i give a request
C:\Program Files\IBM\LDAP\bin>ldapsearch -b "o=ibm,c=us" -h 9.182.174.71 -p 636 -D cn=roo
-w root1 -Z -K "C:\Program Files\ibm\ldap\etc\client.kdb" -P client -s sub cn=s* cn sn
it gave me proper results
but using a JNDI API where i specify
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
// Specify LDAPS URL
env.put(Context.PROVIDER_URL, "ldap://"+"9.182.174.71:636");
// Authenticate as S. User and password "mysecret"
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=root1");
env.put(Context.SECURITY_CREDENTIALS, "root1");
DirContext ctx = new InitialDirContext(env);
SearchControls constraintssc=new SearchControls();
constraintssc.setSearchScope(SearchControls.SUBTREE_SCOPE);
// performing the search
NamingEnumeration results=ctx.search("o=ibm,c=us","cn=s*",constraintssc);
////etc.........
Its gives me an exception saying that
javax.naming.CommunicationException: simple bind failed: 9.182.174.71:636. Root
exception is javax.net.ssl.SSLHandshakeException: Couldn't find trusted certificate
Could any body help me out on this
Thank YouYou are attempting to authenticate via an SSL connection to port 636.
The message 'couldn't find trusted certificate' means that your client doesn't trust the certificate it has received from the LDAP server.
In order to establish that trust, you must export a certificate file from the LDAP server, then use Java's keytool.exe to create a keystore file using that certificate. Then your client code must reference that keystore file that you've created.
So essentially, you have to provide your program the LDAP server's credentials. "If the server's certificate looks like this, then you can trust it."
After your program trusts the certificate it receives from the server at runtime, your connection will authenticate. -
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,
BaraniAre you trying to call the portlet Customization form directly from the browser?
-
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?
-
How to create a group in ldap using jndi?
Hi,
where may I find docs for ""adding users to groups", and creating groups?
Please help,
Thankyou.In Active Directory
"Memberof" and the name of the DN -
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,
AbhijeetHi,
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 -
Clafirication on Login Detials when using JNDI in Toplink
Hi,
I am using Toplink in my application for connecting to Database using JNDI ,which is specified in session.xml ,given below
<toplink-configuration>
<session>
<name>default</name>
<project-xml>META-INF/toplinkMapping.xml</project-xml>
<session-type>
<server-session/>
</session-type>
<login>
<datasource>jdbc/PROD</datasource>
</login>
</session>
</toplink-configuration>
but in the toplinkMapping.xml mapping file i also have an entry for Login Credentials .
The partial xml mapping file for Login details is given below.
<toplink:login xsi:type="toplink:database-login">
<toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</toplink:platform-class>
<toplink:user-name>stage</toplink:user-name>
<toplink:password>0186BD6F6439FA38D570EB1C6286D1EB41782C546151871A</toplink:password>
<toplink:driver-class>oracle.jdbc.OracleDriver</toplink:driver-class>
<toplink:connection-url>jdbc:oracle:thin:@localhost:1522:DEV</toplink:connection-url>
</toplink:login>
Can anyone please explain why the login details are required here in the mapping file ,while iam connecting DataBase through JNDI using DataSources in the Session.xml
Thanks in advanceHi Jeremy,
I've tried adding:
php_value upload_max_filesize 30M
to the .htaccess file but I get a 500 Internal Server Error
Seems like using .htaccess files has been deactivated by your host.
Please try with adding...
...on line 1 of the script which needs that, and see if that works -- if even this doesn´t work, I fear I can´t provide any other suggestion than transferring your site to a hosting provider which handles stuff the standard way and doesn´t force you to use such odd workarounds, which I have never heard of.
Sorry, needed to get that off my chest, but some hosting companies out there are really strange :-)
The problem is that I use the php.ini files to override the server setting
I suspect (can be wrong though) that the php.ini file placed in whatever directory will start "from scratch" everytime a document in that folder is "triggered", and that´s why the session of page A are getting destroyed on page B
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Retrieving user and group information from LDAP using j_securrity_check
Hi
I am using j_security_check to authenticate users against LDAP. I have made all necessary configuration for the server to perform LDAP group search as well as mentioned in the WAS documentation of LDAP settings. Now, how can I retrieve the user and the user group info after the j_secuirty_check. Apart from the UserPrincipal object which I can get from the request which just has the user name, is there any other object which will give me the user and user group info by which I need to connect to LDAP using my java code to retrieve these informations?
Regards
DeepakHi
I am using j_security_check to authenticate users
against LDAP. I have made all necessary configuration
for the server to perform LDAP group search as well
as mentioned in the WAS documentation of LDAP
settings. Now, how can I retrieve the user and the
user group info after the j_secuirty_check.
Apart
from the UserPrincipal object which I can get from
the request which just has the user name, is there
any other object which will give me the user and user
group info by which I need to connect to LDAP using
my java code to retrieve these informations?Hmm, you don't need the user group info to connect to the LDAP server, right? You would need the user's Id (which you have) and password (which you don't). You could use the LDAP credentials and bind as that to look up the user info via the user id. Or if the server is set up to allow anonymous bind you could do it without credentials. But if all you want is group info then you should be able to call Security.getCurrentSubject().getPrincipals() to get the user principal as well as all groups (this is true in BEA WebLogic at least).
Good Luck
Lee -
Create base dn using JNDI...
Hi
I want to create the base dn for OpenDJ LDAP using JNDI below is the code i am using for the same but it is thorwing me the error could any body help me to tell me where exactly i am doing wrong .
public static String ldapUri = "ldap://169.144.104.75:389";
public static String admindn = "cn=Directory Manager";
public static String admincred = "redhat";
public static void main(String args[]){
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapUri);
env.put( Context.SECURITY_PRINCIPAL, admindn );
env.put( Context.SECURITY_CREDENTIALS, admincred );
try {
DirContext ctx = new InitialDirContext(env);
Attributes attrs = new BasicAttributes(true);
Attribute objclass = new BasicAttribute("objectclass");
objclass.add("top");
objclass.add("domain");
objclass.add("ds-cfg-branch");
attrs.put(objclass);
attrs.put("dn","ds-cfg-backend-id=userRoot,cn=Backends,cn=config");
ctx.createSubcontext("dc=naren1,dc=naren1",attrs);
ctx.close();
The error is am getting is
javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry dc=naren1,dc=naren1 cannot be added because its suffix is not defined as one of the suffixes within the Directory Server]; remaining name 'dc=naren1,dc=naren1'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3057)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2978)I want to create the base dn on the OpenDJ and i have used the above mentioned code to create the basedn .
I am the confing file where this entry should be created
dn: ds-cfg-backend-id=userRoot,cn=Backends,cn=config
objectClass: ds-cfg-backend
objectClass: top
objectClass: ds-cfg-local-db-backend
ds-cfg-preload-time-limit: 0 seconds
ds-cfg-compact-encoding: true
ds-cfg-db-checkpointer-bytes-interval: 20 megabytes
ds-cfg-db-logging-level: CONFIG
ds-cfg-db-checkpointer-wakeup-interval: 30 seconds
ds-cfg-disk-full-threshold: 20 megabytes
ds-cfg-db-evictor-keep-alive: 600 seconds
ds-cfg-disk-low-threshold: 100 megabytes
ds-cfg-db-directory: db
ds-cfg-base-dn: dc=com
ds-cfg-base-dn: dc=ex,dc=com1
ds-cfg-base-dn: dc=exam,dc=com2
I have also read one artical on the same http://stackoverflow.com/questions/8977946/how-to-create-new-base-dn-using-jndi
But unable to find the error . If any body can help who had worked on to create the base dn on LDAP. -
Sample code to connect LDAP server using jndi
Hi,
can any one help me with sample code to connect LDAP server using jndi,
like i want to make use of Ldap server for serching Active directoty.
Thanks in advance,
Regards
MuthuYou can set ldap_auth=none for anonymous user.
User/password is mandatory otherwise. Please refer to http://docs.oracle.com/cd/E21764_01/integrate.1111/e12644/appendix_ldap_driver.htm#CHDHCABH
Thansk, -
Setting up LDAP Server to lookup Connection Factories using JNDI
Can someone let me know how to setup LDAP server within 10G to lookup connection factories using JNDI?
I read through the Advanced Queuing User Guide and Reference document where this is mentioned and it says use the Database Configuration Assistant to do this but I could not find how.
When I install 10G is LDAP server automatically setup? How do I get to it?
ThanksThat is correct. I was indeed able to use the app server (10g) to give the LDAP user permission to access the objects, then used sql commands to register the objects inside the LDAP.
However, I am finding NOTHING about actually creating a unique connection factory that can be registered in the LDAP. I find reference to registering Queues/Topics/Factories inside the LDAP, but nothing about actually creating the factories.
In fact, here
http://download.oracle.com/docs/cd/B28359_01/server.111/b28420/aq_envir.htm#sthref409
it's listed that you cannot use sql to create a connectionfactory... not to mention the create java commands for factories look strikingly similar to the queue/topic GET commands, and not the create commands. You can add an alias for that factory using sql, but can't actually create the factory using sql... ??? -
Please Help. How can you monitor a directory using jndi connection to a ldap server?
How can you monitor a directory using jndi connection to a ldap server? I
want the ldap server to monitor the content change in a file system
directory on another computer on the network. Can someone please help.
Thanks
FredHi,
Why do you want to use LDAP for Hard disk monitoring..???
U can do this by creating a MD5 checksum for all the files existing in some
perticular
directory and every hour or any configurable period u can recalculate the
checksum
to find out the change in the content.
I guess all u need is to get the code for "updatedb" utility of Linux and
instrument it for ur needs..
Hope it helps...
-aseem
mr wrote:
How can you monitor a directory using jndi connection to a ldap server? I
want the ldap server to monitor the content change in a file system
directory on another computer on the network. Can someone please help.
Thanks
Fred -
Using JNDI to connect LDAP directory : pb of reconnection
Hi everybody !
I really need our help.
I work with java servlets and i try to connect a LDAP directory with JNDI.
When i launch my application, and when LDAP server is ready, connection is done, i get data from ldap, everything is ok.
But when ldap server fails down, and startup, (my application doesn't stop), i can't connect again to ldap (ldap connext is not null). I get an error "Connection reset by peer, socket write error".
I can't connect, even if i put my context null, and build another context, to get ldap data.
Maybe its a problem of servlet programmation, or JNDI use, i don't know.
Any ideas ?? Thanks you so much for your help !
Here i give my code, to build ldap context (which is equivalent to a connection to ldap) :
_env = new Hashtable();
env.put(Context.INITIALCONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDERURL, "ldap://"+_ldapIPAddress+"/o=netcentrex");
//securite
env.put(Context.SECURITYAUTHENTICATION, "simple");
env.put(Context.SECURITYPRINCIPAL, "cn=admin, o=div");
env.put(Context.SECURITYCREDENTIALS, "admin");
try
ldapCtx = new InitialDirContext(env);
catch(NamingException e)
System.out.println("ConnectionLdap : Cannot get directory context for LDAP");Sorry, no need to reply !!
I've found my error (3 days i am searching, and its a stupid null ldap address) !!!
Maybe you are looking for
-
Cant restore after installing updates how do I change the home user/account
I installed 3 updates, opps, this morning, and when I restarted the computer it had reverted back to old setting from 2004. I purchased the computer from a friend, and had worked hard to remove his stuff, now my settings mail etc are gone and the old
-
Hello- I suck at Linux and networking, especially when someone takes away all the extras.... That said I really like Arch because I'm finally learning what I really need (or am missing) and what it's used for. I'm currently running Arch64 in a box
-
How can I link to an article in different issue?
What is the best way to make a link from article A in issue x to article B in issue y? Every day we refer to articles published in the past, and it would be great to be able to tap the reference, and get the referred article/folio.
-
Need to block someone from calling me on FaceTime
I need to block a number from my iphone5 completely but the number can still get through FaceTime. What can I do? I already blocked the number on sprints side.
-
Hi everybody, I want to know the function module to get F1 help for parameter or select options Thanks in Advance, [email protected]