本文整理匯總了Java中javax.naming.directory.SearchResult.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchResult.getName方法的具體用法?Java SearchResult.getName怎麽用?Java SearchResult.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.directory.SearchResult
的用法示例。
在下文中一共展示了SearchResult.getName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decodeSearchResult
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
/**
* Converts a JNDI SearchResult into our LdapEntry object.
*/
private LdapEntry decodeSearchResult(
SearchResult sr,
String contextBase,
String[] attrNames)
throws LdapException
{
// print dn == distinguished name
String dn;
if (sr.getName() == null || sr.getName().length() == 0)
dn = contextBase;
else dn = sr.getName() + "," + contextBase;
Attributes attrraw = sr.getAttributes();
return decodeAttributes( dn, attrNames, attrraw);
}
示例2: retrieveName
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
String retrieveName(Properties ldapProps, SearchResult res) {
String name = "";
if (res.isRelative()) {
name = res.getName();
} else {
name = res.getNameInNamespace();
String urlName = res.getName();
int index = urlName.lastIndexOf("/");
if (index > 0) {
ldapProps.put(Context.PROVIDER_URL,
urlName.substring(0, index));
}
}
return name;
}
示例3: formatGroupId
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
private String formatGroupId(SearchResult sResult) {
if (null == sResult) {
return "";
}
String groupId = "";
String userDN = sResult.getName();
if (userDN.length() <= 0) {
return "";
}
String[] strings = userDN.split(",");
String loginbaseDN = ldapConfig.get("loginbasedn");
String rootOU = loginbaseDN.substring(loginbaseDN.indexOf("=") + 1, loginbaseDN.indexOf(","));
for (int i = 1; i < strings.length; i++) {
String s = strings[i];
s = s.substring(s.indexOf("=") + 1);
if (s.equals(rootOU)) {
break;
}
groupId = s + "/" + groupId;
}
groupId = groupId.substring(0, groupId.length() - 1);
return groupId;
}