Link to home
Start Free TrialLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

If there's no front end at the server you can get these from then try getting them from the server log
Avatar of mte01

ASKER

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)
Avatar of mte01

ASKER

also this is my url:

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

you're missing trailing /

Avatar of mte01

ASKER

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.

> 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)

Avatar of mte01

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mte01

ASKER

Thanks for the help.