?
Solved

JNDI naming and user authentication (extra parameters)

Posted on 2009-02-24
11
Medium Priority
?
229 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:mte01
  • 5
  • 4
  • 2
11 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 23719474
If there's no front end at the server you can get these from then try getting them from the server log
0
 
LVL 3

Author Comment

by:mte01
ID: 23719555
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:mte01
ID: 23719560
also this is my url:

String ldapurl = "ldap://192.168.0.149:389";
0
 
LVL 92

Expert Comment

by:objects
ID: 23719585
> String ldapurl = "ldap://192.168.0.149:389";

you're missing trailing /

0
 
LVL 3

Author Comment

by:mte01
ID: 23719647
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
 
LVL 92

Expert Comment

by:objects
ID: 23719662
> 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
 
LVL 3

Author Comment

by:mte01
ID: 23719754
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
 
LVL 92

Accepted Solution

by:
objects earned 1200 total points
ID: 23719808
you need to know your schema in order to be able to make a query

0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 800 total points
ID: 23719838
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
 
LVL 3

Author Closing Comment

by:mte01
ID: 31550481
Thanks for the help.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question