/** * Parses the supplied return attributes and applies the following convention: * * <ul> * <li>null == {@link ReturnAttributes#DEFAULT}</li> * </ul> * * @param attrs to parse * * @return parsed attributes according to convention */ public static String[] parse(final String... attrs) { if (attrs == null) { return ReturnAttributes.DEFAULT.value(); } return attrs; } }
/** * Parses the supplied return attributes and applies the following convention: * * <ul> * <li>null == {@link ReturnAttributes#DEFAULT}</li> * </ul> * * @param attrs to parse * * @return parsed attributes according to convention */ public static String[] parse(final String... attrs) { if (attrs == null) { return ReturnAttributes.DEFAULT.value(); } return attrs; } }
/** * Parses the supplied return attributes and applies the following convention: * * <ul> * <li>null == {@link ReturnAttributes#DEFAULT}</li> * </ul> * * @param attrs to parse * * @return parsed attributes according to convention */ public static String[] parse(final String... attrs) { if (attrs == null) { return ReturnAttributes.DEFAULT.value(); } return attrs; } }
/** * Builds a new request. * * @param baseDn the base dn * @param filter the filter * @return the search request */ public static SearchRequest newSearchRequest(final String baseDn, final SearchFilter filter) { final SearchRequest sr = new SearchRequest(baseDn, filter); sr.setBinaryAttributes(ReturnAttributes.ALL_USER.value()); sr.setReturnAttributes(ReturnAttributes.ALL_USER.value()); sr.setSearchScope(SearchScope.SUBTREE); return sr; }
/** * Builds a new request. * * @param baseDn the base dn * @param filter the filter * @return the search request */ public static SearchRequest createSearchRequest(final String baseDn, final SearchFilter filter) { final SearchRequest sr = new SearchRequest(baseDn, filter); sr.setBinaryAttributes(ReturnAttributes.ALL_USER.value()); sr.setReturnAttributes(ReturnAttributes.ALL_USER.value()); sr.setSearchScope(SearchScope.SUBTREE); return sr; }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the schema entries * * @return schema * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getSearchResult(factory, entryDn, "(objectClass=*)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the subschema entry * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the subschema entry * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the schema entries * * @return schema * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getSearchResult(factory, entryDn, "(objectClass=*)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the schema entries * * @return schema * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getSearchResult(factory, entryDn, "(objectClass=*)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The entryDn is searched to obtain the schema. * * @param factory to obtain an LDAP connection from * @param entryDn the subschema entry * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory, final String entryDn) throws LdapException { return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The subschema subentry is searched for on the root DSE, followed by searching for the * subschema entry itself. * * @param factory to obtain an LDAP connection from * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory) throws LdapException { final LdapEntry rootDSE = getLdapEntry(factory, "", "(objectClass=*)", new String[] {SUBSCHEMA_SUBENTRY_ATTR_NAME}); final String entryDn = rootDSE.getAttribute(SUBSCHEMA_SUBENTRY_ATTR_NAME).getStringValue(); return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The subschema subentry is searched for on the root DSE, followed by searching for the * subschema entry itself. * * @param factory to obtain an LDAP connection from * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory) throws LdapException { final LdapEntry rootDSE = getLdapEntry(factory, "", "(objectClass=*)", new String[] {SUBSCHEMA_SUBENTRY_ATTR_NAME}); final String entryDn = rootDSE.getAttribute(SUBSCHEMA_SUBENTRY_ATTR_NAME).getStringValue(); return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** * Creates a new schema. The subschema subentry is searched for on the root DSE, followed by searching for the * subschema entry itself. * * @param factory to obtain an LDAP connection from * * @return schema created from the connection factory * * @throws LdapException if the search fails */ public static Schema createSchema(final ConnectionFactory factory) throws LdapException { final LdapEntry rootDSE = getLdapEntry(factory, "", "(objectClass=*)", new String[] {SUBSCHEMA_SUBENTRY_ATTR_NAME}); final String entryDn = rootDSE.getAttribute(SUBSCHEMA_SUBENTRY_ATTR_NAME).getStringValue(); return createSchema(getLdapEntry(factory, entryDn, "(objectClass=subSchema)", ReturnAttributes.ALL.value())); }
/** Creates a new search validator. */ public SearchValidator() { searchRequest = new SearchRequest(); searchRequest.setBaseDn(""); searchRequest.setSearchFilter(new SearchFilter("(objectClass=*)")); searchRequest.setReturnAttributes(ReturnAttributes.NONE.value()); searchRequest.setSearchScope(SearchScope.OBJECT); searchRequest.setSizeLimit(1); }
/** Creates a new search validator. */ public SearchValidator() { searchRequest = new SearchRequest(); searchRequest.setBaseDn(""); searchRequest.setSearchFilter(new SearchFilter("(objectClass=*)")); searchRequest.setReturnAttributes(ReturnAttributes.NONE.value()); searchRequest.setSearchScope(SearchScope.OBJECT); searchRequest.setSizeLimit(1); }
/** * New search executor search executor. * * @param baseDn the base dn * @param filterQuery the filter query * @param params the params * @return the search executor */ public static SearchExecutor newSearchExecutor(final String baseDn, final String filterQuery, final String... params) { final SearchExecutor executor = new SearchExecutor(); executor.setBaseDn(baseDn); executor.setSearchFilter(newSearchFilter(filterQuery, params)); executor.setReturnAttributes(ReturnAttributes.ALL.value()); executor.setSearchScope(SearchScope.SUBTREE); return executor; } }
/** Creates a new search validator. */ public SearchValidator() { searchRequest = new SearchRequest(); searchRequest.setBaseDn(""); searchRequest.setSearchFilter(new SearchFilter("(objectClass=*)")); searchRequest.setReturnAttributes(ReturnAttributes.NONE.value()); searchRequest.setSearchScope(SearchScope.OBJECT); searchRequest.setSizeLimit(1); }
/** * Creates a search request from a search filter. * * @param filter LDAP search filter. * @return ldaptive search request. */ private SearchRequest createRequest(final SearchFilter filter) { final SearchRequest request = new SearchRequest(); request.setBaseDn(this.baseDN); request.setSearchFilter(filter); /** LDAP attributes to fetch from search results. */ if (getResultAttributeMapping() != null && !getResultAttributeMapping().isEmpty()) { final String[] attributes = getResultAttributeMapping().keySet().toArray(new String[getResultAttributeMapping().size()]); request.setReturnAttributes(attributes); } else if (searchControls.getReturningAttributes() != null && searchControls.getReturningAttributes().length > 0) { request.setReturnAttributes(searchControls.getReturningAttributes()); } else { request.setReturnAttributes(ReturnAttributes.ALL_USER.value()); } request.setSearchScope(this.searchScope); request.setSizeLimit(this.searchControls.getCountLimit()); request.setTimeLimit(Duration.ofSeconds(searchControls.getTimeLimit())); return request; }
/** * Returns a search request for searching for a single entry in an LDAP, returning no attributes. * * @param filter to execute * * @return search request */ protected SearchRequest createSearchRequest(final SearchFilter filter) { final SearchRequest request = new SearchRequest(); request.setBaseDn(baseDn); request.setSearchFilter(filter); request.setReturnAttributes(ReturnAttributes.NONE.value()); if (subtreeSearch) { request.setSearchScope(SearchScope.SUBTREE); } else { request.setSearchScope(SearchScope.ONELEVEL); } request.setDerefAliases(derefAliases); request.setReferralHandler(referralHandler); return request; }