mte01
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
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
If there's no front end at the server you can get these from then try getting them from the server log
you need to query the ldap server
http://java.sun.com/products/jndi/tutorial/ldap/misc/url.html
http://www.stonemind.net/blog/2008/01/23/a-simple-ldap-query-program-in-java/
http://java.sun.com/products/jndi/tutorial/ldap/misc/url.html
http://www.stonemind.net/blog/2008/01/23/a-simple-ldap-query-program-in-java/
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(Search Controls.S UBTREE_SCO PE);
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)).ge tAll();
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(Conte xt.SECURIT Y_PRINCIPA L,"MYCOMPA NY\\omar") ;
ctx.addToEnvironment(Conte xt.SECURIT Y_CREDENTI ALS,"testT EST123456" );
ctx.reconnect(connCtls);
>> what are the ou.. sn... o
best,
following is the exception:
javax.naming.NameNotFoundE xception: [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. mapErrorCo de(LdapCtx .java:3010 )
at com.sun.jndi.ldap.LdapCtx. processRet urnCode(Ld apCtx.java :2931)
at com.sun.jndi.ldap.LdapCtx. processRet urnCode(Ld apCtx.java :2737)
at com.sun.jndi.ldap.LdapCtx. searchAux( LdapCtx.ja va:1808)
at com.sun.jndi.ldap.LdapCtx. c_search(L dapCtx.jav a:1731)
at com.sun.jndi.toolkit.ctx.C omponentDi rContext.p _search(Co mponentDir Context.ja va:368)
at com.sun.jndi.toolkit.ctx.P artialComp ositeDirCo ntext.sear ch(Partial CompositeD irContext. java:338)
at com.sun.jndi.toolkit.ctx.P artialComp ositeDirCo ntext.sear ch(Partial CompositeD irContext. java:321)
at javax.naming.directory.Ini tialDirCon text.searc h(InitialD irContext. java:248)
at com.compressus.cstation.ac tion.EditA ctiveDirec toryServer .Authentic ate(EditAc tiveDirect oryServer. java:114)
at com.compressus.cstation.ac tion.EditA ctiveDirec toryServer .test(Edit ActiveDire ctoryServe r.java:51)
at com.compressus.cstation.ac tion.EditA ctiveDirec toryServer .execute(E ditActiveD irectorySe rver.java: 29)
at com.cme.commons.action.Hib ernateActi on.execute (Hibernate Action.jav a:36)
at org.apache.struts.action.R equestProc essor.proc essActionP erform(Req uestProces sor.java:4 21)
at org.apache.struts.action.R equestProc essor.proc ess(Reques tProcessor .java:226)
at org.apache.struts.action.A ctionServl et.process (ActionSer vlet.java: 1164)
at org.apache.struts.action.A ctionServl et.doGet(A ctionServl et.java:39 7)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 740)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:213)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.coyote.http11.H ttp11Proce ssor.proce ss(Http11P rocessor.j ava:869)
at org.apache.coyote.http11.H ttp11BaseP rotocol$Ht tp11Connec tionHandle r.processC onnection( Http11Base Protocol.j ava:664)
at org.apache.tomcat.util.net .PoolTcpEn dpoint.pro cessSocket (PoolTcpEn dpoint.jav a:527)
at org.apache.tomcat.util.net .LeaderFol lowerWorke rThread.ru nIt(Leader FollowerWo rkerThread .java:80)
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
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(Search
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)).ge
while (values.hasMore()) {
if (output.length() > 0) {
output.append("|");
}
output.append(values.next(
}
}
note that omar is a user on my system that i can validate his credentials when i call this:
ctx.addToEnvironment(Conte
ctx.addToEnvironment(Conte
ctx.reconnect(connCtls);
>> what are the ou.. sn... o
best,
following is the exception:
javax.naming.NameNotFoundE
''
; remaining name ''
at com.sun.jndi.ldap.LdapCtx.
at com.sun.jndi.ldap.LdapCtx.
at com.sun.jndi.ldap.LdapCtx.
at com.sun.jndi.ldap.LdapCtx.
at com.sun.jndi.ldap.LdapCtx.
at com.sun.jndi.toolkit.ctx.C
at com.sun.jndi.toolkit.ctx.P
at com.sun.jndi.toolkit.ctx.P
at javax.naming.directory.Ini
at com.compressus.cstation.ac
at com.compressus.cstation.ac
at com.compressus.cstation.ac
at com.cme.commons.action.Hib
at org.apache.struts.action.R
at org.apache.struts.action.R
at org.apache.struts.action.A
at org.apache.struts.action.A
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at org.apache.tomcat.util.net
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
ASKER
also this is my url:
String ldapurl = "ldap://192.168.0.149:389" ;
String ldapurl = "ldap://192.168.0.149:389"
> String ldapurl = "ldap://192.168.0.149:389" ;
you're missing trailing /
you're missing trailing /
ASKER
the URL from your example is:
String url = "ldap://directory.cornell. edu/o=Corn ell%20Univ ersity,c=U S"
what are these: o=Cornell%20University,c=U S
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(Conte xt.SECURIT Y_PRINCIPA L,"MYCOMPA NY\\omar") ;
thanks for the quick replies, really appreciated.
String url = "ldap://directory.cornell.
what are these: o=Cornell%20University,c=U
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(Conte
thanks for the quick replies, really appreciated.
> what are these: o=Cornell%20University,c=U S
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)
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)
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
String ldapurl = "ldap://192.168.0.149:389/
as for this one:
String ldapurl = "ldap://192.168.0.149:389/
String ldapurl = "ldap://192.168.0.149:389/
String ldapurl = "ldap://192.168.0.149:389/
String ldapurl = "ldap://192.168.0.149:389/
String ldapurl = "ldap://192.168.0.149:389/
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help.