use of javax.naming.directory.BasicAttributes in project jackrabbit-oak by apache.
the class InternalLdapServer method addMembers.
public void addMembers(String groupDN, Iterable<String> memberDNs) throws Exception {
LdapContext ctxt = getWiredContext();
Attribute attr = new BasicAttribute("member");
for (String dn : memberDNs) {
attr.add(dn);
}
BasicAttributes attrs = new BasicAttributes();
attrs.put(attr);
ctxt.modifyAttributes(groupDN, DirContext.ADD_ATTRIBUTE, attrs);
}
use of javax.naming.directory.BasicAttributes in project jackrabbit-oak by apache.
the class InternalLdapServer method removeMember.
public void removeMember(String groupDN, String memberDN) throws Exception {
LdapContext ctxt = getWiredContext();
BasicAttributes attrs = new BasicAttributes();
attrs.put("member", memberDN);
ctxt.modifyAttributes(groupDN, DirContext.REMOVE_ATTRIBUTE, attrs);
}
use of javax.naming.directory.BasicAttributes in project jmeter by apache.
the class LDAPExtSampler method getUserAttributes.
/***************************************************************************
* Collect all the values from the table (Arguments), using this create the
* Attributes, this will create the Attributes for the User
* defined TestCase for Add Test
*
* @return The Attributes
**************************************************************************/
private Attributes getUserAttributes() {
Attributes attrs = new BasicAttributes(true);
Attribute attr;
for (JMeterProperty jMeterProperty : getArguments()) {
Argument item = (Argument) jMeterProperty.getObjectValue();
attr = attrs.get(item.getName());
if (attr == null) {
attr = getBasicAttribute(item.getName(), item.getValue());
} else {
attr.add(item.getValue());
}
attrs.put(attr);
}
return attrs;
}
use of javax.naming.directory.BasicAttributes in project jmeter by apache.
the class LDAPSampler method getBasicAttributes.
/**
* This will create the Basic Attributes for the In build TestCase for Add
* Test.
*
* @return the BasicAttributes
*/
private BasicAttributes getBasicAttributes() {
BasicAttributes basicattributes = new BasicAttributes();
//$NON-NLS-1$
BasicAttribute basicattribute = new BasicAttribute("objectclass");
//$NON-NLS-1$
basicattribute.add("top");
//$NON-NLS-1$
basicattribute.add("person");
//$NON-NLS-1$
basicattribute.add("organizationalPerson");
//$NON-NLS-1$
basicattribute.add("inetOrgPerson");
basicattributes.put(basicattribute);
//$NON-NLS-1$
String s1 = "User";
//$NON-NLS-1$
String s3 = "Test";
//$NON-NLS-1$
String s5 = "user";
//$NON-NLS-1$
String s6 = "test";
COUNTER.incrementAndGet();
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("givenname", s1));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("sn", s3));
//$NON-NLS-1$ //$NON-NLS-2$
basicattributes.put(new BasicAttribute("cn", "TestUser" + COUNTER.get()));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("uid", s5));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("userpassword", s6));
//$NON-NLS-1$
setProperty(new StringProperty(ADD, "cn=TestUser" + COUNTER.get()));
return basicattributes;
}
use of javax.naming.directory.BasicAttributes in project fess by codelibs.
the class LdapManager method insert.
public void insert(final Group group) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (!fessConfig.isLdapAdminEnabled()) {
return;
}
final Supplier<Hashtable<String, String>> adminEnv = () -> createAdminEnv();
final String entryDN = fessConfig.getLdapAdminGroupSecurityPrincipal(group.getName());
search(fessConfig.getLdapAdminGroupBaseDn(), fessConfig.getLdapAdminGroupFilter(group.getName()), null, adminEnv, result -> {
if (!result.isEmpty()) {
logger.info("{} exists in LDAP server.", group.getName());
modifyGroupAttributes(group, adminEnv, entryDN, result, fessConfig);
} else {
final BasicAttributes entry = new BasicAttributes();
addGroupAttributes(entry, group, fessConfig);
final Attribute oc = fessConfig.getLdapAdminGroupObjectClassAttribute();
entry.put(oc);
insert(entryDN, entry, adminEnv);
}
});
}
Aggregations