@Nullable private String getAttribute(@NotNull SearchResultEntry entry, @NotNull String name) { Attribute attribute = entry.getAttribute(name); return attribute == null ? null : attribute.getValue(); }
} else { Attribute attribute = userSearchResult.getAttribute(nameMapping); if (attribute != null && attribute.hasValue()) { account.setName(attribute.getValue()); } else { Attribute attribute = userSearchResult.getAttribute(emailMapping); if (attribute != null && attribute.hasValue()) { account.addEmailAddress(attribute.getValue());
} else { Attribute attribute = userSearchResult.getAttribute(nameMapping); if (attribute != null && attribute.hasValue()) { account.setName(attribute.getValue()); } else { Attribute attribute = userSearchResult.getAttribute(emailMapping); if (attribute != null && attribute.hasValue()) { account.addEmailAddress(attribute.getValue());
@Override public ILdapAttribute getAttribute(String key) { return new DefaultLdapAttribute(elem.getAttribute(key)); }
private void setAccountRoles(LDAPConnection ldapConnection, SearchResultEntry accountSearchResult, Account account) { String accountDN = accountSearchResult.getDN(); String groupMemberPattern = this.groupMemberPattern.replace("${dn}", escapeLDAPSearchFilter(accountDN)); groupMemberPattern = groupMemberPattern.replace("${username}", escapeLDAPSearchFilter(account.getUsername())); // Fill in attributes into groupMemberPattern for (Attribute attribute : accountSearchResult.getAttributes()) { groupMemberPattern = groupMemberPattern.replace("${" + attribute.getName() + "}", escapeLDAPSearchFilter(attribute.getValue())); } SearchResult groupsSearchResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn")); if (groupsSearchResult != null && groupsSearchResult.getEntryCount() > 0) { for (int i = 0; i < groupsSearchResult.getEntryCount(); i++) { SearchResultEntry groupEntry = groupsSearchResult.getSearchEntries().get(i); String roleName = groupEntry.getAttribute("cn").getValue(); account.getAuthorizations().addRole(roleName); } } }
@Override public ILdapAttribute getAttribute(String key) { return new DefaultLdapAttribute(elem.getAttribute(key)); }
private void setAccountRoles(LDAPConnection ldapConnection, SearchResultEntry accountSearchResult, Account account) { String accountDN = accountSearchResult.getDN(); String groupMemberPattern = this.groupMemberPattern.replace("${dn}", escapeLDAPSearchFilter(accountDN)); groupMemberPattern = groupMemberPattern.replace("${username}", escapeLDAPSearchFilter(account.getUsername())); // Fill in attributes into groupMemberPattern for (Attribute attribute : accountSearchResult.getAttributes()) { groupMemberPattern = groupMemberPattern.replace("${" + attribute.getName() + "}", escapeLDAPSearchFilter(attribute.getValue())); } SearchResult groupsSearchResult = doSearch(ldapConnection, groupBase, true, groupMemberPattern, Arrays.asList("cn")); if (groupsSearchResult != null && groupsSearchResult.getEntryCount() > 0) { for (int i = 0; i < groupsSearchResult.getEntryCount(); i++) { SearchResultEntry groupEntry = groupsSearchResult.getSearchEntries().get(i); String roleName = groupEntry.getAttribute("cn").getValue(); account.getAuthorizations().addRole(roleName); } } }
.getSearchEntries()) { Attribute attribute = searchResultEntry .getAttribute("sAMAccountName"); String samAccountName = attribute.getValue();
searchResult.getSearchEntries().get(0).getAttribute(attrName); if (a == null)