Exemplo n.º 1
0
 private Object[] getSearchParameter(final LdapEntry entry) {
   switch (searchBy) {
     case SIMPLE:
       return new String[] {entry.getSimpleName()};
     default:
       return new String[] {entry.getDistinguishedName()};
   }
 }
Exemplo n.º 2
0
    @Override
    public LdapEntry[] groupSearch(DirContext dirContext, LdapEntry entry)
        throws IOException, NamingException {
      Set<LdapEntry> foundEntries = new HashSet<LdapEntry>();
      // Load the list of group.
      Attributes groups =
          dirContext.getAttributes(entry.getDistinguishedName(), new String[] {groupAttribute});
      Attribute groupRef = groups.get(groupAttribute);
      if (groupRef != null && groupRef.size() > 0) {
        NamingEnumeration<String> groupRefValues = (NamingEnumeration<String>) groupRef.getAll();
        while (groupRefValues.hasMore()) {
          String distingushedName = groupRefValues.next();
          SECURITY_LOGGER.tracef("Group found with distinguishedName=%s", distingushedName);
          String simpleName = null;
          if (groupNameAttribute != null) {
            // Load the Name
            Attributes groupNameAttrs =
                dirContext.getAttributes(distingushedName, new String[] {groupNameAttribute});
            Attribute groupNameAttr = groupNameAttrs.get(groupNameAttribute);
            simpleName = (String) groupNameAttr.get();
            SECURITY_LOGGER.tracef(
                "simpleName %s loaded for group with distinguishedName=%s",
                simpleName, distingushedName);
          } else {
            SECURITY_LOGGER.trace("No groupNameAttribute to load simpleName");
          }
          foundEntries.add(new LdapEntry(simpleName, distingushedName));
        }
      } else {
        SECURITY_LOGGER.tracef("No groups found for %s", entry);
      }

      return foundEntries.toArray(new LdapEntry[foundEntries.size()]);
    }
  @Override
  protected void getAdditionalProperties(Multimap<String, String> additionalProperties) {
    super.getAdditionalProperties(additionalProperties);

    additionalProperties.put("o", organizationName);
    additionalProperties.put("dc", getCn());
  }
  @Override
  protected void getObjectClasses(List<String> objectClasses) {
    super.getObjectClasses(objectClasses);

    objectClasses.add("dcObject");
    objectClasses.add("organization");
    if (isTop()) objectClasses.add("top");
  }