Search in sources :

Example 16 with BasicAttributes

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);
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) LdapContext(javax.naming.ldap.LdapContext)

Example 17 with BasicAttributes

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);
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) LdapContext(javax.naming.ldap.LdapContext)

Example 18 with BasicAttributes

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;
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) LDAPArgument(org.apache.jmeter.protocol.ldap.config.gui.LDAPArgument) Argument(org.apache.jmeter.config.Argument) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes)

Example 19 with BasicAttributes

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;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) StringProperty(org.apache.jmeter.testelement.property.StringProperty)

Example 20 with 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);
        }
    });
}
Also used : BasicAttributes(javax.naming.directory.BasicAttributes) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) Hashtable(java.util.Hashtable) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Aggregations

BasicAttributes (javax.naming.directory.BasicAttributes)42 BasicAttribute (javax.naming.directory.BasicAttribute)32 Attribute (javax.naming.directory.Attribute)25 Attributes (javax.naming.directory.Attributes)25 Test (org.junit.Test)9 File (java.io.File)7 HashSet (java.util.HashSet)7 MutablePartitionConfiguration (org.apache.directory.server.core.configuration.MutablePartitionConfiguration)7 AbstractBootstrapSchema (org.apache.directory.server.core.schema.bootstrap.AbstractBootstrapSchema)7 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 DirContext (javax.naming.directory.DirContext)5 PrivkeySchema (org.nhindirect.ldap.PrivkeySchema)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)4 Hashtable (java.util.Hashtable)4 NamingException (javax.naming.NamingException)4 SearchControls (javax.naming.directory.SearchControls)4 SearchResult (javax.naming.directory.SearchResult)4 Lookup (org.nhindirect.stagent.cert.impl.util.Lookup)4 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)3