Java Code Examples for org.apache.directory.api.ldap.model.message.SearchScope#OBJECT
The following examples show how to use
org.apache.directory.api.ldap.model.message.SearchScope#OBJECT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public EntryFilteringCursor search( Dn dn, String filter, boolean ignoreReferrals ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); ExprNode filterNode = null; try { filterNode = FilterParser.parse( directoryService.getSchemaManager(), filter ); } catch ( ParseException pe ) { throw new LdapInvalidSearchFilterException( pe.getMessage() ); } SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.OBJECT, filterNode, ( String ) null ); searchContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS ); setReferralHandling( searchContext, ignoreReferrals ); return operationManager.search( searchContext ); }
Example 2
Source File: DefaultCoreSession.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public Cursor<Entry> search( Dn dn, String filter, boolean ignoreReferrals ) throws LdapException { OperationManager operationManager = directoryService.getOperationManager(); ExprNode filterNode = null; try { filterNode = FilterParser.parse( directoryService.getSchemaManager(), filter ); } catch ( ParseException pe ) { throw new LdapInvalidSearchFilterException( pe.getMessage() ); } SearchOperationContext searchContext = new SearchOperationContext( this, dn, SearchScope.OBJECT, filterNode, ( String ) null ); searchContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS ); setReferralHandling( searchContext, ignoreReferrals ); return operationManager.search( searchContext ); }
Example 3
Source File: LdapUrl.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Construct an empty LdapUrl */ public LdapUrl() { scheme = LDAP_SCHEME; host = null; port = -1; dn = null; attributes = new ArrayList<>(); scope = SearchScope.OBJECT; filter = null; extensionList = new ArrayList<>( 2 ); }
Example 4
Source File: LdapUrl.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Sets the scope. Must be one of {@link SearchScope#OBJECT}, * {@link SearchScope#ONELEVEL} or {@link SearchScope#SUBTREE}, * otherwise {@link SearchScope#OBJECT} is assumed as default. * * @param scope the new scope */ public void setScope( int scope ) { try { this.scope = SearchScope.getSearchScope( scope ); } catch ( IllegalArgumentException iae ) { this.scope = SearchScope.OBJECT; } }
Example 5
Source File: LdapUrl.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Sets the scope. Must be one of {@link SearchScope#OBJECT}, * {@link SearchScope#ONELEVEL} or {@link SearchScope#SUBTREE}, * otherwise {@link SearchScope#OBJECT} is assumed as default. * * @param scope the new scope */ public void setScope( SearchScope scope ) { if ( scope == null ) { this.scope = SearchScope.OBJECT; } else { this.scope = scope; } }
Example 6
Source File: SearchRequestDsml.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public Element toDsml( Element root ) { Element element = super.toDsml( root ); SearchRequest request = getDecorated(); // Dn if ( request.getBase() != null ) { element.addAttribute( "dn", request.getBase().getName() ); } // Scope SearchScope scope = request.getScope(); if ( scope != null ) { if ( scope == SearchScope.OBJECT ) { element.addAttribute( "scope", "baseObject" ); } else if ( scope == SearchScope.ONELEVEL ) { element.addAttribute( "scope", "singleLevel" ); } else if ( scope == SearchScope.SUBTREE ) { element.addAttribute( "scope", "wholeSubtree" ); } } // DerefAliases AliasDerefMode derefAliases = request.getDerefAliases(); switch ( derefAliases ) { case NEVER_DEREF_ALIASES: element.addAttribute( DEREF_ALIASES, "neverDerefAliases" ); break; case DEREF_ALWAYS: element.addAttribute( DEREF_ALIASES, "derefAlways" ); break; case DEREF_FINDING_BASE_OBJ: element.addAttribute( DEREF_ALIASES, "derefFindingBaseObj" ); break; case DEREF_IN_SEARCHING: element.addAttribute( DEREF_ALIASES, "derefInSearching" ); break; default: throw new IllegalStateException( I18n.err( I18n.ERR_03043_UNEXPECTED_DEREF_ALIAS, derefAliases ) ); } // SizeLimit if ( request.getSizeLimit() != 0L ) { element.addAttribute( "sizeLimit", Long.toString( request.getSizeLimit() ) ); } // TimeLimit if ( request.getTimeLimit() != 0 ) { element.addAttribute( "timeLimit", Integer.toString( request.getTimeLimit() ) ); } // TypesOnly if ( request.getTypesOnly() ) { element.addAttribute( "typesOnly", "true" ); } // Filter Element filterElement = element.addElement( "filter" ); toDsml( filterElement, request.getFilter() ); // Attributes List<String> attributes = request.getAttributes(); if ( !attributes.isEmpty() ) { Element attributesElement = element.addElement( "attributes" ); for ( String entryAttribute : attributes ) { attributesElement.addElement( "attribute" ).addAttribute( NAME, entryAttribute ); } } return element; }
Example 7
Source File: LdapUrl.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Parse the scope part. * * @param chars The char array to be checked * @param pos the starting position * @return -1 if the char array does not contains a scope */ private int parseScope( char[] chars, int pos ) { if ( Chars.isCharASCII( chars, pos, 'b' ) || Chars.isCharASCII( chars, pos, 'B' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'a' ) || Chars.isCharASCII( chars, pos, 'A' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 's' ) || Chars.isCharASCII( chars, pos, 'S' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'e' ) || Chars.isCharASCII( chars, pos, 'E' ) ) { pos++; scope = SearchScope.OBJECT; return pos; } } } } else if ( Chars.isCharASCII( chars, pos, 'o' ) || Chars.isCharASCII( chars, pos, 'O' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'n' ) || Chars.isCharASCII( chars, pos, 'N' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'e' ) || Chars.isCharASCII( chars, pos, 'E' ) ) { pos++; scope = SearchScope.ONELEVEL; return pos; } } } else if ( Chars.isCharASCII( chars, pos, 's' ) || Chars.isCharASCII( chars, pos, 'S' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'u' ) || Chars.isCharASCII( chars, pos, 'U' ) ) { pos++; if ( Chars.isCharASCII( chars, pos, 'b' ) || Chars.isCharASCII( chars, pos, 'B' ) ) { pos++; scope = SearchScope.SUBTREE; return pos; } } } else if ( Chars.isCharASCII( chars, pos, '?' ) ) { // An empty scope. This is valid return pos; } else if ( pos == chars.length ) { // An empty scope at the end of the URL. This is valid return pos; } // The scope is not one of "one", "sub" or "base". It's an error return -1; }
Example 8
Source File: StoredProcedureSearchContextOption.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Instantiates a new stored procedure search context option. * * @param baseObject the base object */ public StoredProcedureSearchContextOption( Dn baseObject ) { // the default search scope is "base" this( baseObject, SearchScope.OBJECT ); }
Example 9
Source File: SearchRequestHandler.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
/** * Handles the RootDSE and lookups searches */ private boolean handleLookupAndRootDse( LdapSession session, SearchRequest req ) throws Exception { boolean isBaseScope = req.getScope() == SearchScope.OBJECT; boolean isObjectClassFilter = false; if ( req.getFilter() instanceof PresenceNode ) { ExprNode filter = req.getFilter(); if ( filter.isSchemaAware() ) { AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType(); isObjectClassFilter = attributeType.equals( OBJECT_CLASS_AT ); } else { String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute(); isObjectClassFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID ); } } /* if ( isBaseScope && isObjectClassFilter ) { // This is a lookup handleLookup( session, req ); return true; } else { // a standard search return false; } */ boolean isBaseIsRoot = req.getBase().isEmpty(); if ( isBaseScope && isObjectClassFilter ) { if ( isBaseIsRoot ) { // This is a rootDse lookup handleLookup( session, req ); return true; } else { // This is a lookup //handleLookup( session, req ); return false; } } else { // a standard search return false; } }
Example 10
Source File: SearchRequestHandler.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
/** * Handles the RootDSE and lookups searches */ private boolean handleLookupAndRootDse( LdapSession session, SearchRequest req ) throws Exception { boolean isBaseScope = req.getScope() == SearchScope.OBJECT; boolean isObjectClassFilter = false; if ( req.getFilter() instanceof PresenceNode ) { ExprNode filter = req.getFilter(); if ( filter.isSchemaAware() ) { AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType(); isObjectClassFilter = attributeType.equals( OBJECT_CLASS_AT ); } else { String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute(); isObjectClassFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID ); } } /* if ( isBaseScope && isObjectClassFilter ) { // This is a lookup handleLookup( session, req ); return true; } else { // a standard search return false; } */ boolean isBaseIsRoot = req.getBase().isEmpty(); if ( isBaseScope && isObjectClassFilter ) { if ( isBaseIsRoot ) { // This is a rootDse lookup handleLookup( session, req ); return true; } else { // This is a lookup //handleLookup( session, req ); return false; } } else { // a standard search return false; } }