Search in sources :

Example 71 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class StaticGroup method getMemberCount.

/**
     * Gets the member count.
     * 
     * @param level
     *            Nesting level
     * @return Number of members of the group
     * @exception Not
     *                thrown by this class
     * @supported.api
     */
public int getMemberCount(int level) throws UMSException {
    if (level == LEVEL_ALL) {
        level = getMaxNestingLevel();
    }
    if (level == LEVEL_DIRECT) {
        Attr attr = getAttribute(MEMBER_ATTR_NAME);
        return (attr != null) ? attr.size() : 0;
    }
    SearchResults allMembers = getMembers(level);
    if (allMembers == null)
        return 0;
    int count = 0;
    while (allMembers.hasMoreElements()) {
        allMembers.next();
        count++;
    }
    return count;
}
Also used : Attr(com.iplanet.services.ldap.Attr)

Example 72 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class StaticGroup method addMember.

/**
     * Adds a member to the group. The change is saved to
     * persistent storage.
     * 
     * @param guid
     *            Globally unique identifier for the member to be added
     * @exception UMSException
     *                on failure to save to persistent storage
     * @supported.api
     */
public void addMember(Guid guid) throws UMSException {
    String id = guid.getDn();
    PersistentObject entry = null;
    try {
        entry = UMSObject.getObject(getPrincipal(), guid);
    } catch (UMSException ignore) {
    }
    if (entry != null && entry instanceof StaticGroup) {
        StaticGroup g = (StaticGroup) entry;
        if (id.equalsIgnoreCase(getDN()) || g.hasMember(getGuid(), LEVEL_ALL)) {
            throw new UMSException(i18n.getString(IUMSConstants.NO_RECURSION_ALLOW));
        }
    }
    modify(new Attr(MEMBER_ATTR_NAME, id), ModificationType.ADD);
    save();
}
Also used : ByteString(org.forgerock.opendj.ldap.ByteString) Attr(com.iplanet.services.ldap.Attr)

Example 73 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class StaticGroup method getMembers.

/**
     * Get members of the group.
     * 
     * @param level
     *            Nesting level
     * @return SearchResults for members of the group
     * @exception Not
     *                thrown by this class
     * @supported.api
     * 
     */
public SearchResults getMembers(int level) throws UMSException {
    Attr attr = getAttribute(MEMBER_ATTR_NAME);
    if (attr == null) {
        return null;
    }
    if (level == LEVEL_ALL) {
        level = getMaxNestingLevel();
    }
    if (level == LEVEL_DIRECT) {
        return new SearchResults(getAttribute(MEMBER_ATTR_NAME));
    }
    Attr nestedMembers = new Attr(MEMBER_ATTR_NAME);
    Attribute la = attr.toLDAPAttribute();
    Iterator<ByteString> iterator = la.iterator();
    while (iterator.hasNext()) {
        String memberdn = iterator.next().toString();
        PersistentObject entry = null;
        try {
            // entry = getUMSSession().getObject(new Guid(memberdn));
            entry = UMSObject.getObject(getPrincipal(), new Guid(memberdn));
        } catch (UMSException ignore) {
        }
        if (entry != null && entry instanceof StaticGroup) {
            SearchResults r = ((StaticGroup) entry).getMembers(level - 1);
            while (r.hasMoreElements()) {
                PersistentObject member = null;
                try {
                    member = r.next();
                    nestedMembers.addValue(member.getDN());
                } catch (UMSException ignore) {
                }
            }
        } else {
            nestedMembers.addValue(memberdn);
        }
        entry = null;
    }
    return new SearchResults(nestedMembers);
}
Also used : Attribute(org.forgerock.opendj.ldap.Attribute) ByteString(org.forgerock.opendj.ldap.ByteString) ByteString(org.forgerock.opendj.ldap.ByteString) Attr(com.iplanet.services.ldap.Attr)

Example 74 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class TemplateManager method toAttrSet.

private AttrSet toAttrSet(CreationTemplate t) {
    AttrSet attrSet = new AttrSet();
    attrSet.add(new Attr(TemplateManager.TEMPLATE_NAME, t.getName()));
    attrSet.add(new Attr(TemplateManager.TEMPLATE_NAMINGATTRIBUTE, t.getNamingAttribute()));
    ArrayList classes = t.getCreationClasses();
    String[] classNames = new String[classes.size()];
    for (int i = 0; i < classes.size(); i++) {
        Class cls = (Class) classes.get(i);
        classNames[i] = cls.getName();
    }
    attrSet.add(new Attr(TemplateManager.TEMPLATE_JAVACLASS, classNames));
    Attr required = encodeAttrSet(TemplateManager.TEMPLATE_REQUIRED, t.getRequiredAttributeSet(), "=");
    if (required != null) {
        attrSet.add(required);
    }
    Attr optional = encodeAttrSet(TemplateManager.TEMPLATE_OPTIONAL, t.getOptionalAttributeSet(), "=");
    if (optional != null) {
        attrSet.add(optional);
    }
    Attr validated = encodeAttrSet(TemplateManager.TEMPLATE_VALIDATED, t.getValidation(), "=");
    if (validated != null) {
        attrSet.add(validated);
    }
    return attrSet;
}
Also used : ArrayList(java.util.ArrayList) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 75 with Attr

use of com.iplanet.services.ldap.Attr in project OpenAM by OpenRock.

the class PeopleContainer method setMaxChildPeopleContainerLimit.

/**
     * Sets max children People Container limit for a People Container.
     * 
     * @param limit
     *            number of children People Containers allowed
     * @supported.api
     */
public void setMaxChildPeopleContainerLimit(long limit) throws UMSException {
    String value = (new Long(limit)).toString();
    setAttribute(new Attr(MAX_PEOPLECONTAINER_ATTR_NAME, value));
}
Also used : Attr(com.iplanet.services.ldap.Attr)

Aggregations

Attr (com.iplanet.services.ldap.Attr)89 AttrSet (com.iplanet.services.ldap.AttrSet)34 Guid (com.iplanet.ums.Guid)16 Iterator (java.util.Iterator)15 UMSException (com.iplanet.ums.UMSException)14 PersistentObject (com.iplanet.ums.PersistentObject)12 HashSet (java.util.HashSet)12 Set (java.util.Set)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 ByteString (org.forgerock.opendj.ldap.ByteString)9 AMException (com.iplanet.am.sdk.AMException)7 SSOException (com.iplanet.sso.SSOException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 Enumeration (java.util.Enumeration)4 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)3 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)3 CreationTemplate (com.iplanet.ums.CreationTemplate)3 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)3