JNDI naming and user authentication (extra parameters)

Hi all,
i'm using the following example http://forums.sun.com/thread.jspa?threadID=726601&tstart=0 for JNDI naming and user authentication.

how can i get the user's information "parameters" from the server!? like user's full name, mail....

thanks
LVL 3
mte01Asked:
Who is Participating?
 
objectsCommented:
you need to know your schema in order to be able to make a query

0
 
CEHJCommented:
If there's no front end at the server you can get these from then try getting them from the server log
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
mte01Author Commented:
Hi and thanks for the fast reply


i got the following exception upon trying the example from this site: http://www.stonemind.net/blog/2008/01/23/a-simple-ldap-query-program-in-java/


String query = "uid=" + "omar";
               String attribute = "pdsRoles";
               DirContext context = new InitialDirContext(env);
               SearchControls ctrl = new SearchControls();
                 ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
                 NamingEnumeration enumeration = ctx.search("", query, ctrl);
                 StringBuffer output = new StringBuffer();
 
                 while (enumeration.hasMore()) {
                      SearchResult result = (SearchResult) enumeration.next();
                      Attributes attribs = result.getAttributes();
                      NamingEnumeration values = ((BasicAttribute) attribs.get(attribute)).getAll();
                      while (values.hasMore()) {
                        if (output.length() > 0) {
                          output.append("|");
                        }
                        output.append(values.next().toString());
                      }
                  }



note that omar is a user on my system that i can validate his credentials when i call this:

ctx.addToEnvironment(Context.SECURITY_PRINCIPAL,"MYCOMPANY\\omar");
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS,"testTEST123456");
ctx.reconnect(connCtls);

>> what are the ou.. sn... o
best,


following is the exception:
javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001A1, problem 2001 (NO_OBJECT), data 0, best match of:
      ''
; remaining name ''
      at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3010)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
      at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
      at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1808)
      at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1731)
      at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
      at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:321)
      at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:248)
      at com.compressus.cstation.action.EditActiveDirectoryServer.Authenticate(EditActiveDirectoryServer.java:114)
      at com.compressus.cstation.action.EditActiveDirectoryServer.test(EditActiveDirectoryServer.java:51)
      at com.compressus.cstation.action.EditActiveDirectoryServer.execute(EditActiveDirectoryServer.java:29)
      at com.cme.commons.action.HibernateAction.execute(HibernateAction.java:36)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
      at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
0
 
mte01Author Commented:
also this is my url:

String ldapurl = "ldap://192.168.0.149:389";
0
 
objectsCommented:
> String ldapurl = "ldap://192.168.0.149:389";

you're missing trailing /

0
 
mte01Author Commented:
the URL from your example is:

String url = "ldap://directory.cornell.edu/o=Cornell%20University,c=US"

what are these: o=Cornell%20University,c=US

the URL im using is: String ldapurl = "ldap://192.168.0.149:389";

what am i missing im my URL?
please note that this is the username that im using: "MYCOMPANY\\omar"

-- ctx.addToEnvironment(Context.SECURITY_PRINCIPAL,"MYCOMPANY\\omar");


thanks for the quick replies, really appreciated.

0
 
objectsCommented:
> what are these: o=Cornell%20University,c=US

attributes of the context to search in

> what am i missing im my URL?

at least a / at the end
String ldapurl = "ldap://192.168.0.149:389/";
perhaps also the context of your search (ie. where in the tree to look)

0
 
mte01Author Commented:
this one is not returning any result: (still giving the same exception)
String ldapurl = "ldap://192.168.0.149:389/";

as for this one:
String ldapurl = "ldap://192.168.0.149:389/MYCOMPANY";
String ldapurl = "ldap://192.168.0.149:389/MYCOMPANY/";
String ldapurl = "ldap://192.168.0.149:389/MYCOMPANY.local";
String ldapurl = "ldap://192.168.0.149:389/local";
String ldapurl = "ldap://192.168.0.149:389/Users";


non of the above are working, i did attach the screenshot of the AD server configuration, please take a look at it and tell me if i missed something.
best,


screenshot.JPG
0
 
CEHJCommented:
I would suggest you get a tool to perform ldap queries before you start writing them in Java, or you'll have a tough double learning curve:

http://www.securityxploded.com/ldapsearch.php
0
 
mte01Author Commented:
Thanks for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.