Revision 8459
Added by Jing Tao about 11 years ago
src/edu/ucsb/nceas/metacat/AuthLdap.java | ||
---|---|---|
304 | 304 |
return authenticated; |
305 | 305 |
} |
306 | 306 |
|
307 |
/* |
|
308 |
* Get the aliasedDN (the real DN) for a specified an alias name |
|
309 |
*/ |
|
310 |
public String getAliasedDn(String alias, Hashtable<String, String> env) throws NamingException { |
|
311 |
String aliasedDn = null; |
|
312 |
DirContext sctx = new InitialDirContext(env); |
|
313 |
SearchControls ctls = new SearchControls(); |
|
314 |
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); |
|
315 |
String filter = "(objectClass=*)"; |
|
316 |
NamingEnumeration answer = sctx.search(alias, filter, ctls); |
|
317 |
while(answer.hasMore()) { |
|
318 |
SearchResult result = (SearchResult) answer.next(); |
|
319 |
if(!result.isRelative()) { |
|
320 |
//if is not relative, this will be alias. |
|
321 |
aliasedDn = result.getNameInNamespace(); |
|
322 |
break; |
|
323 |
} |
|
324 |
} |
|
325 |
return aliasedDn; |
|
326 |
|
|
327 |
} |
|
307 | 328 |
private boolean authenticateTLS(Hashtable<String, String> env, String userDN, String password) |
308 | 329 |
throws AuthTLSException{ |
309 | 330 |
logMetacat.info("AuthLdap.authenticateTLS - Trying to authenticate with TLS"); |
Also available in: Unified diff
Add a method to get the aliasedDn.