Search in sources :

Example 1 with DN

use of com.unboundid.ldap.sdk.DN in project jbpm by kiegroup.

the class LdapJbpmTestCase method startDirectoryServer.

@Before
public void startDirectoryServer() throws LDAPException {
    InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", 10389);
    InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN("dc=jboss,dc=org"));
    serverConfig.setListenerConfigs(listenerConfig);
    serverConfig.addAdditionalBindCredentials("uid=admin,ou=system", "secret");
    serverConfig.setSchema(null);
    server = new InMemoryDirectoryServer(serverConfig);
    server.importFromLDIF(false, ldif);
    server.startListening();
}
Also used : InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) InMemoryDirectoryServerConfig(com.unboundid.ldap.listener.InMemoryDirectoryServerConfig) InMemoryListenerConfig(com.unboundid.ldap.listener.InMemoryListenerConfig) DN(com.unboundid.ldap.sdk.DN) Before(org.junit.Before)

Example 2 with DN

use of com.unboundid.ldap.sdk.DN in project zm-mailbox by Zimbra.

the class UBIDLdapContext method renameEntry.

@Override
public void renameEntry(String oldDn, String newDn) throws LdapException {
    try {
        DN newDN = new DN(newDn);
        String newRDN = newDN.getRDNString();
        String newSuperiorDN = newDN.getParentString();
        UBIDLdapOperation.MODIFY_DN.execute(this, oldDn, newRDN, true, newSuperiorDN);
    } catch (LDAPException e) {
        throw mapToLdapException("unable to rename entry", e);
    }
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) DN(com.unboundid.ldap.sdk.DN) ASN1OctetString(com.unboundid.asn1.ASN1OctetString)

Example 3 with DN

use of com.unboundid.ldap.sdk.DN in project zm-mailbox by Zimbra.

the class UBIDLdapContext method moveChildren.

@Override
public void moveChildren(String oldDn, String newDn) throws ServiceException {
    try {
        // use ZLdapFilter instead of just the native Filter so it's
        // convenient for stating
        ZLdapFilter filter = ZLdapFilterFactory.getInstance().anyEntry();
        // Filter filter = Filter.createPresenceFilter(LdapConstants.ATTR_OBJECTCLASS);
        SearchRequest searchRequest = new SearchRequest(oldDn, SearchScope.ONE, derefAliasPolicy, // size limit
        0, // time limit
        0, // getTypesOnly
        false, ((UBIDLdapFilter) filter).getNative());
        searchRequest.setAttributes("dn");
        SearchResult result = UBIDLdapOperation.SEARCH.execute(this, searchRequest, filter);
        List<SearchResultEntry> entries = result.getSearchEntries();
        for (SearchResultEntry entry : entries) {
            DN entryDN = entry.getParsedDN();
            String childDn = entryDN.toNormalizedString();
            String childRdn = entryDN.getRDNString();
            UBIDLdapOperation.MODIFY_DN.execute(this, childDn, childRdn, true, newDn);
        }
    } catch (LDAPException e) {
        throw mapToLdapException("unable to move children", e);
    }
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) SearchRequest(com.unboundid.ldap.sdk.SearchRequest) LDAPException(com.unboundid.ldap.sdk.LDAPException) SearchResult(com.unboundid.ldap.sdk.SearchResult) DN(com.unboundid.ldap.sdk.DN) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) SearchResultEntry(com.unboundid.ldap.sdk.SearchResultEntry)

Example 4 with DN

use of com.unboundid.ldap.sdk.DN in project gocd by gocd.

the class InMemoryLdapServerForTests method startServer.

private InMemoryDirectoryServer startServer(int port, String baseDn, String bindDn, String bindPassword) throws LDAPException, BindException {
    InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", port);
    InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN(baseDn));
    /* Ignore schema so that it does not complain that some attributes (like sAMAccountName) are not valid. */
    serverConfig.setSchema(null);
    serverConfig.setListenerConfigs(listenerConfig);
    serverConfig.addAdditionalBindCredentials(bindDn, bindPassword);
    InMemoryDirectoryServer server = new InMemoryDirectoryServer(serverConfig);
    try {
        server.startListening();
    } catch (LDAPException e) {
        throw new RuntimeException(e);
    }
    new LDIFAddChangeRecord(baseDn, new Attribute("objectClass", "domain", "top")).processChange(server);
    return server;
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) Attribute(com.unboundid.ldap.sdk.Attribute) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) InMemoryDirectoryServerConfig(com.unboundid.ldap.listener.InMemoryDirectoryServerConfig) InMemoryListenerConfig(com.unboundid.ldap.listener.InMemoryListenerConfig) DN(com.unboundid.ldap.sdk.DN)

Example 5 with DN

use of com.unboundid.ldap.sdk.DN in project oxAuth by GluuFederation.

the class InumGenerator method baseDn.

public String baseDn(IdType p_type) {
    final BaseDnConfiguration baseDn = staticConfiguration.getBaseDn();
    switch(p_type) {
        case CLIENTS:
            return baseDn.getClients();
        case APPLIANCE:
            return baseDn.getAppliance();
        case ATTRIBUTE:
            return baseDn.getAttributes();
        case PEOPLE:
            return baseDn.getPeople();
    }
    // if not able to identify baseDn by type then return organization baseDn, e.g. o=gluu
    try {
        // baseDn.getClients(), e.g. ou=clients,o=@!1111,o=gluu
        final DN dnObj = new DN(baseDn.getClients());
        final RDN[] rdns = dnObj.getRDNs();
        final RDN rdn = rdns[rdns.length - 1];
        return rdn.toNormalizedString();
    } catch (LDAPException e) {
        log.error(e.getMessage(), e);
    }
    log.error("Use fallback DN: o=gluu, for ID generator, please check oxAuth configuration, clientDn must be valid DN");
    return "o=gluu";
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) BaseDnConfiguration(org.xdi.oxauth.model.config.BaseDnConfiguration) RDN(com.unboundid.ldap.sdk.RDN)

Aggregations

DN (com.unboundid.ldap.sdk.DN)9 LDAPException (com.unboundid.ldap.sdk.LDAPException)6 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)5 InMemoryDirectoryServerConfig (com.unboundid.ldap.listener.InMemoryDirectoryServerConfig)4 InMemoryListenerConfig (com.unboundid.ldap.listener.InMemoryListenerConfig)3 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)2 RDN (com.unboundid.ldap.sdk.RDN)2 Before (org.junit.Before)2 Attribute (com.unboundid.ldap.sdk.Attribute)1 Entry (com.unboundid.ldap.sdk.Entry)1 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)1 SearchResult (com.unboundid.ldap.sdk.SearchResult)1 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)1 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)1 ZLdapFilter (com.zimbra.cs.ldap.ZLdapFilter)1 Test (org.junit.jupiter.api.Test)1 BaseDnConfiguration (org.xdi.oxauth.model.config.BaseDnConfiguration)1