Revision 8463
Added by Jing Tao almost 11 years ago
src/edu/ucsb/nceas/metacat/AuthLdap.java | ||
---|---|---|
338 | 338 |
|
339 | 339 |
|
340 | 340 |
/* |
341 |
* Get the aliased dn through a TLS connection |
|
341 |
* Get the aliased dn through a TLS connection. The null will be returned if there is no real name associated with the alias
|
|
342 | 342 |
*/ |
343 | 343 |
private String getAliasedDnTLS(String alias, Hashtable<String, String> env) throws NamingException, IOException { |
344 | 344 |
boolean useTLS = true; |
... | ... | |
346 | 346 |
} |
347 | 347 |
|
348 | 348 |
/* |
349 |
* Get the aliased dn through a non-TLS connection |
|
349 |
* Get the aliased dn through a non-TLS connection. The null will be returned if there is no real name associated with the alias
|
|
350 | 350 |
*/ |
351 | 351 |
private String getAliasedDnNonTLS(String alias, Hashtable<String, String> env) throws NamingException, IOException { |
352 | 352 |
boolean useTLS = false; |
... | ... | |
634 | 634 |
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); |
635 | 635 |
env.put(Context.REFERRAL, referral); |
636 | 636 |
env.put(Context.PROVIDER_URL, ldapUrl); |
637 |
String realName = null; |
|
638 |
try { |
|
639 |
realName = getAliasedDnNonTLS(user,env); |
|
640 |
} catch(Exception e) { |
|
641 |
logMetacat.warn("AuthLdap.getUserInfo - can't get the alias name for the user "+user+" since "+e.getMessage()); |
|
642 |
} |
|
643 |
|
|
644 |
if(realName != null) { |
|
645 |
//the the user is an alias name. we need to use the the real name |
|
646 |
user = realName; |
|
647 |
} |
|
637 | 648 |
|
638 | 649 |
try { |
639 | 650 |
|
... | ... | |
814 | 825 |
env.put(Context.REFERRAL, "throw"); |
815 | 826 |
env.put(Context.PROVIDER_URL, ldapUrl); |
816 | 827 |
env.put("com.sun.jndi.ldap.connect.timeout", ldapConnectTimeLimit); |
817 |
|
|
828 |
String realName = null; |
|
829 |
try { |
|
830 |
realName = getAliasedDnNonTLS(foruser,env); |
|
831 |
} catch(Exception e) { |
|
832 |
logMetacat.warn("AuthLdap.getGroups - can't get the alias name for the user "+user+" since "+e.getMessage()); |
|
833 |
} |
|
834 |
|
|
835 |
if(realName != null) { |
|
836 |
//the the user is an alias name. we need to use the the real name |
|
837 |
foruser = realName; |
|
838 |
} |
|
818 | 839 |
// Iterate through the referrals, handling NamingExceptions in the |
819 | 840 |
// outer catch statement, ReferralExceptions in the inner catch |
820 | 841 |
// statement |
Also available in: Unified diff
Add code to get user info and group info for an alias.