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;
}
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();
}
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);
}
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;
}
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));
}
Aggregations