idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
42,400
public function getMemberOf ( ) { $ dns = $ this -> getAttribute ( $ this -> schema -> memberOf ( ) ) ; return is_array ( $ dns ) ? $ dns : [ ] ; }
Returns an array of distinguished names of groups that the current model belongs to .
42,401
public function addGroup ( $ group ) { if ( is_string ( $ group ) ) { $ group = $ this -> query -> newInstance ( ) -> findByDn ( $ group ) ; } if ( $ group instanceof Group ) { return $ group -> addMember ( $ this -> getDn ( ) ) ; } return false ; }
Adds the current model to the specified group .
42,402
public function removeGroup ( $ group ) { if ( is_string ( $ group ) ) { $ group = $ this -> query -> newInstance ( ) -> findByDn ( $ group ) ; } if ( $ group instanceof Group ) { return $ group -> removeMember ( $ this -> getDn ( ) ) ; } return false ; }
Removes the current model from the specified group .
42,403
public function removeAllGroups ( ) { $ removed = [ ] ; foreach ( $ this -> getMemberOf ( ) as $ group ) { if ( $ this -> removeGroup ( $ group ) ) { $ removed [ ] = $ group ; } } return $ removed ; }
Removes the current model from all groups .
42,404
public function getGroups ( array $ fields = [ '*' ] , $ recursive = false , array $ visited = [ ] ) { if ( ! in_array ( $ this -> schema -> memberOf ( ) , $ fields ) ) { $ fields = array_merge ( $ fields , [ $ this -> schema -> memberOf ( ) ] ) ; } $ groups = $ this -> getGroupsByNames ( $ this -> getMemberOf ( ) , $ ...
Returns the models groups that it is apart of .
42,405
public function getGroupNames ( $ recursive = false ) { $ fields = [ $ this -> schema -> commonName ( ) , $ this -> schema -> memberOf ( ) ] ; $ names = $ this -> getGroups ( $ fields , $ recursive ) -> map ( function ( Group $ group ) { return $ group -> getCommonName ( ) ; } ) -> toArray ( ) ; return array_unique ( $...
Returns the models groups names in a single dimension array .
42,406
protected function getGroupsByNames ( array $ dns = [ ] , $ fields = [ ] ) { $ query = $ this -> query -> newInstance ( ) ; return $ query -> newCollection ( $ dns ) -> map ( function ( $ dn ) use ( $ query , $ fields ) { return $ query -> select ( $ fields ) -> findByDn ( $ dn ) ; } ) -> filter ( function ( $ group ) ...
Retrieves groups by their distinguished name .
42,407
protected function groupIsParent ( $ group , Group $ parent ) { if ( $ group instanceof Group ) { return $ parent -> getDn ( ) === $ group -> getDn ( ) ; } if ( Utilities :: explodeDn ( $ group ) ) { return $ parent -> getDn ( ) === $ group ; } if ( ! empty ( $ group ) ) { return $ parent -> getCommonName ( ) === $ gro...
Validates if the specified group is the given parent instance .
42,408
public function set ( $ propName , $ propValue ) { $ this -> validateProp ( $ propName ) ; $ this -> getTsPropObj ( $ propName ) -> setValue ( $ propValue ) ; return $ this ; }
Set the value for a specific TSProperty by its name .
42,409
public function toArray ( ) { $ userParameters = [ ] ; foreach ( $ this -> tsProperty as $ property => $ tsPropObj ) { $ userParameters [ $ property ] = $ tsPropObj -> getValue ( ) ; } return $ userParameters ; }
Get a simple associative array containing of all TSProperty names and values .
42,410
protected function decodeUserParameters ( $ userParameters ) { $ userParameters = bin2hex ( $ userParameters ) ; $ this -> preBinary = hex2bin ( substr ( $ userParameters , 0 , 96 ) ) ; $ this -> signature = MbString :: chr ( hexdec ( substr ( $ userParameters , 96 , 2 ) ) ) ; if ( $ this -> signature != self :: VALID_...
Get an associative array with all of the userParameters property names and values .
42,411
protected function addTSPropData ( $ tsPropertyArray , $ tsPropCount ) { $ length = 0 ; for ( $ i = 0 ; $ i < $ tsPropCount ; $ i ++ ) { $ propLength = hexdec ( substr ( $ tsPropertyArray , $ length , 2 ) ) + ( hexdec ( substr ( $ tsPropertyArray , $ length + 2 , 2 ) ) * 3 ) + 6 ; $ tsProperty = new TSProperty ( hex2bi...
Given the start of TSPropertyArray hex data and the count for the number of TSProperty structures in contains parse and split out the individual TSProperty structures . Return the full length of the TSPropertyArray data .
42,412
protected function applyPrefixAndSuffix ( $ username ) { $ prefix = $ this -> configuration -> get ( 'account_prefix' ) ; $ suffix = $ this -> configuration -> get ( 'account_suffix' ) ; return $ prefix . $ username . $ suffix ; }
Applies the prefix and suffix to the given username .
42,413
protected function fireAttemptingEvent ( $ username , $ password ) { if ( isset ( $ this -> events ) ) { $ this -> events -> fire ( new Attempting ( $ this -> connection , $ username , $ password ) ) ; } }
Fire the attempting event .
42,414
protected function firePassedEvent ( $ username , $ password ) { if ( isset ( $ this -> events ) ) { $ this -> events -> fire ( new Passed ( $ this -> connection , $ username , $ password ) ) ; } }
Fire the passed event .
42,415
protected function fireFailedEvent ( $ username , $ password ) { if ( isset ( $ this -> events ) ) { $ this -> events -> fire ( new Failed ( $ this -> connection , $ username , $ password ) ) ; } }
Fire the failed event .
42,416
protected function fireBindingEvent ( $ username , $ password ) { if ( isset ( $ this -> events ) ) { $ this -> events -> fire ( new Binding ( $ this -> connection , $ username , $ password ) ) ; } }
Fire the binding event .
42,417
protected function fireBoundEvent ( $ username , $ password ) { if ( isset ( $ this -> events ) ) { $ this -> events -> fire ( new Bound ( $ this -> connection , $ username , $ password ) ) ; } }
Fire the bound event .
42,418
public function set ( $ key , $ value ) { if ( $ this -> validate ( $ key , $ value ) ) { $ this -> options [ $ key ] = $ value ; } }
Sets a configuration option .
42,419
protected function validate ( $ key , $ value ) { $ default = $ this -> get ( $ key ) ; if ( is_array ( $ default ) ) { $ validator = new Validators \ ArrayValidator ( $ key , $ value ) ; } elseif ( is_int ( $ default ) ) { $ validator = new Validators \ IntegerValidator ( $ key , $ value ) ; } elseif ( is_bool ( $ def...
Validates the new configuration option against its default value to ensure it s the correct type .
42,420
public function addProxyAddress ( $ address ) { $ addresses = $ this -> getProxyAddresses ( ) ; $ addresses [ ] = $ address ; return $ this -> setAttribute ( $ this -> schema -> proxyAddresses ( ) , $ addresses ) ; }
Add s a single proxy address to the user .
42,421
public function newInstance ( $ baseDn = null ) { $ dn = is_null ( $ baseDn ) ? $ this -> getDn ( ) : $ baseDn ; return ( new static ( $ this -> connection , $ this -> grammar , $ this -> schema ) ) -> setDn ( $ dn ) ; }
Returns a new Query Builder instance .
42,422
public function newNestedInstance ( Closure $ closure = null ) { $ query = $ this -> newInstance ( ) -> nested ( ) ; if ( $ closure ) { call_user_func ( $ closure , $ query ) ; } return $ query ; }
Returns a new nested Query Builder instance .
42,423
public function getQuery ( ) { if ( count ( array_filter ( $ this -> filters ) ) === 0 ) { $ this -> whereHas ( $ this -> schema -> objectClass ( ) ) ; } return $ this -> grammar -> compile ( $ this ) ; }
Compiles and returns the current query string .
42,424
public function setDn ( $ dn = null ) { $ this -> dn = $ dn instanceof Model ? $ dn -> getDn ( ) : $ dn ; return $ this ; }
Sets the DN to perform searches upon .
42,425
public function findMany ( array $ values = [ ] , $ columns = [ ] ) { $ this -> select ( $ columns ) ; if ( ! is_a ( $ this -> schema , ActiveDirectory :: class ) ) { $ query = $ this ; foreach ( $ values as $ value ) { $ query -> prepareAnrEquivalentQuery ( $ value ) ; } return $ query -> get ( ) ; } return $ this -> ...
Finds multiple records using ambiguous name resolution .
42,426
protected function prepareAnrEquivalentQuery ( $ value ) { return $ this -> orFilter ( function ( Builder $ query ) use ( $ value ) { $ locateBy = [ $ this -> schema -> name ( ) , $ this -> schema -> email ( ) , $ this -> schema -> userId ( ) , $ this -> schema -> lastName ( ) , $ this -> schema -> firstName ( ) , $ th...
Creates an ANR equivalent query for LDAP distributions that do not support ANR .
42,427
public function findManyBy ( $ attribute , array $ values = [ ] , $ columns = [ ] ) { $ query = $ this -> select ( $ columns ) ; foreach ( $ values as $ value ) { $ query -> orWhere ( [ $ attribute => $ value ] ) ; } return $ query -> get ( ) ; }
Finds many records by the specified attribute .
42,428
public function rawFilter ( $ filters = [ ] ) { $ filters = is_array ( $ filters ) ? $ filters : func_get_args ( ) ; foreach ( $ filters as $ filter ) { $ this -> filters [ 'raw' ] [ ] = $ filter ; } return $ this ; }
Adds a raw filter to the current query .
42,429
public function andFilter ( Closure $ closure ) { $ query = $ this -> newNestedInstance ( $ closure ) ; $ filter = $ this -> grammar -> compileAnd ( $ query -> getQuery ( ) ) ; return $ this -> rawFilter ( $ filter ) ; }
Adds a nested and filter to the current query .
42,430
public function orFilter ( Closure $ closure ) { $ query = $ this -> newNestedInstance ( $ closure ) ; $ filter = $ this -> grammar -> compileOr ( $ query -> getQuery ( ) ) ; return $ this -> rawFilter ( $ filter ) ; }
Adds a nested or filter to the current query .
42,431
public function notFilter ( Closure $ closure ) { $ query = $ this -> newNestedInstance ( $ closure ) ; $ filter = $ this -> grammar -> compileNot ( $ query -> getQuery ( ) ) ; return $ this -> rawFilter ( $ filter ) ; }
Adds a nested not filter to the current query .
42,432
public function whereRaw ( $ field , $ operator = null , $ value = null ) { return $ this -> where ( $ field , $ operator , $ value , 'and' , true ) ; }
Adds a raw where clause to the current query .
42,433
public function whereIn ( $ field , array $ values ) { return $ this -> orFilter ( function ( Builder $ query ) use ( $ field , $ values ) { foreach ( $ values as $ value ) { $ query -> whereEquals ( $ field , $ value ) ; } } ) ; }
Query for entries that match any of the values provided for the given field .
42,434
public function orWhereRaw ( $ field , $ operator = null , $ value = null ) { return $ this -> where ( $ field , $ operator , $ value , 'or' , true ) ; }
Adds a raw or where clause to the current query .
42,435
public function addFilter ( $ type , array $ bindings ) { if ( ! array_key_exists ( $ type , $ this -> filters ) ) { throw new InvalidArgumentException ( "Invalid filter type: {$type}." ) ; } $ required = [ 'field' , 'operator' , 'value' ] ; if ( count ( array_intersect_key ( array_flip ( $ required ) , $ bindings ) ) ...
Adds a filter onto the current query .
42,436
public function clearFilters ( ) { foreach ( $ this -> filters as $ type => $ filters ) { $ this -> filters [ $ type ] = [ ] ; } return $ this ; }
Clear the query builders filters .
42,437
public function getSelects ( ) { $ selects = $ this -> columns ; if ( ! in_array ( '*' , $ selects ) ) { $ selects [ ] = $ this -> schema -> objectCategory ( ) ; $ selects [ ] = $ this -> schema -> objectClass ( ) ; } return $ selects ; }
Returns the current selected fields to retrieve .
42,438
public function dynamicWhere ( $ method , $ parameters ) { $ finder = substr ( $ method , 5 ) ; $ segments = preg_split ( '/(And|Or)(?=[A-Z])/' , $ finder , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ connector = 'and' ; $ index = 0 ; foreach ( $ segments as $ segment ) { if ( $ segment != 'And' && $ segment != 'Or' ) { $ thi...
Handles dynamic where clauses to the query .
42,439
protected function addArrayOfWheres ( $ wheres , $ boolean , $ raw ) { foreach ( $ wheres as $ key => $ value ) { if ( is_numeric ( $ key ) && is_array ( $ value ) ) { list ( $ field , $ condition ) = $ value ; $ value = Arr :: get ( $ value , 2 ) ; $ this -> where ( $ field , $ condition , $ value , $ boolean ) ; } el...
Adds an array of wheres to the current query .
42,440
public function get ( ) { $ components = [ ] ; foreach ( $ this -> components as $ component => $ values ) { array_map ( function ( $ value ) use ( $ component , & $ components ) { $ components [ ] = sprintf ( '%s=%s' , $ component , ldap_escape ( $ value , '' , 2 ) ) ; } , $ values ) ; } return implode ( ',' , $ compo...
Returns the complete distinguished name by assembling the RDN components .
42,441
public function setBase ( $ base ) { $ base = ( string ) $ base ; $ base = Utilities :: explodeDn ( $ base , false ) ? : [ ] ; unset ( $ base [ 'count' ] ) ; foreach ( $ base as $ key => $ rdn ) { $ pieces = explode ( '=' , $ rdn ) ? : [ ] ; if ( count ( $ pieces ) === 2 ) { $ attribute = ucfirst ( strtolower ( $ piece...
Sets the base RDN of the distinguished name .
42,442
public function getComponents ( $ component = null ) { if ( is_null ( $ component ) ) { return $ this -> components ; } $ this -> validateComponentExists ( $ component ) ; return $ this -> components [ $ component ] ; }
Returns an array of all components in the distinguished name .
42,443
protected function addComponent ( $ component , $ value ) { $ this -> validateComponentExists ( $ component ) ; if ( ! empty ( $ value ) ) { $ this -> components [ $ component ] [ ] = $ value ; } }
Adds a component to the distinguished name .
42,444
protected function removeComponent ( $ component , $ value ) { $ this -> validateComponentExists ( $ component ) ; $ this -> components [ $ component ] = array_diff ( $ this -> components [ $ component ] , [ $ value ] ) ; }
Removes the given value from the given component .
42,445
public function getBinary ( ) { $ sid = explode ( '-' , ltrim ( $ this -> value , 'S-' ) ) ; $ level = ( int ) array_shift ( $ sid ) ; $ authority = ( int ) array_shift ( $ sid ) ; $ subAuthorities = array_map ( 'intval' , $ sid ) ; $ params = array_merge ( [ 'C2xxNV*' , $ level , count ( $ subAuthorities ) , $ authori...
Returns the binary variant of the SID .
42,446
public function setQuery ( $ query , $ baseDn ) { $ this -> query = $ query ; $ this -> baseDn = $ baseDn ; $ this -> message = "No LDAP query results for filter: [{$query}] in: [{$baseDn}]" ; return $ this ; }
Sets the query that was used .
42,447
public function getMembers ( ) { $ members = $ this -> getMembersFromAttribute ( $ this -> schema -> member ( ) ) ; if ( count ( $ members ) === 0 ) { $ members = $ this -> getPaginatedMembers ( ) ; } return $ this -> newCollection ( $ members ) ; }
Returns all users apart of the current group .
42,448
public function getMemberNames ( ) { $ members = [ ] ; $ dns = $ this -> getAttribute ( $ this -> schema -> member ( ) ) ? : [ ] ; foreach ( $ dns as $ dn ) { $ exploded = Utilities :: explodeDn ( $ dn ) ; if ( array_key_exists ( 0 , $ exploded ) ) { $ members [ ] = $ exploded [ 0 ] ; } } return $ members ; }
Returns the group s member names only .
42,449
public function addMembers ( array $ members ) { $ members = array_map ( function ( $ member ) { return $ member instanceof Model ? $ member -> getDn ( ) : $ member ; } , $ members ) ; $ mod = $ this -> newBatchModification ( $ this -> schema -> member ( ) , LDAP_MODIFY_BATCH_ADD , $ members ) ; return $ this -> addMod...
Adds multiple entries to the current group .
42,450
public function addMember ( $ member ) { $ member = ( $ member instanceof Model ? $ member -> getDn ( ) : $ member ) ; if ( is_null ( $ member ) ) { throw new InvalidArgumentException ( 'Cannot add member to group. The members distinguished name cannot be null.' ) ; } $ mod = $ this -> newBatchModification ( $ this -> ...
Adds an entry to the current group .
42,451
public function removeMember ( $ member ) { $ member = ( $ member instanceof Model ? $ member -> getDn ( ) : $ member ) ; if ( is_null ( $ member ) ) { throw new InvalidArgumentException ( 'Cannot remove member to group. The members distinguished name cannot be null.' ) ; } $ mod = $ this -> newBatchModification ( $ th...
Removes an entry from the current group .
42,452
public function removeMembers ( ) { $ mod = $ this -> newBatchModification ( $ this -> schema -> member ( ) , LDAP_MODIFY_BATCH_REMOVE_ALL ) ; return $ this -> addModification ( $ mod ) -> save ( ) ; }
Removes all members from the current group .
42,453
protected function getMembersFromAttribute ( $ attribute ) { $ members = [ ] ; $ entries = $ this -> getAttribute ( $ attribute ) ? : [ ] ; $ query = $ this -> query -> newInstance ( ) ; $ identifier = $ this -> schema -> memberIdentifier ( ) ; foreach ( $ entries as $ entry ) { if ( $ identifier == 'dn' || $ identifie...
Retrieves group members by the specified model attribute .
42,454
protected function getPaginatedMembers ( ) { $ members = [ ] ; $ keys = array_keys ( $ this -> attributes ) ; $ attributes = array_values ( array_filter ( $ keys , function ( $ key ) { return strpos ( $ key , 'member;range' ) !== false ; } ) ) ; $ key = reset ( $ attributes ) ; preg_match_all ( '/member;range\=([0-9]{1...
Retrieves members that are contained in a member range .
42,455
public function users ( ) { $ wheres = [ [ $ this -> schema -> objectClass ( ) , Operator :: $ equals , $ this -> schema -> objectClassUser ( ) ] , [ $ this -> schema -> objectCategory ( ) , Operator :: $ equals , $ this -> schema -> objectCategoryPerson ( ) ] ] ; if ( is_a ( $ this -> schema , ActiveDirectory :: class...
Returns a query builder scoped to users .
42,456
public function getRootDse ( ) { $ query = $ this -> newQuery ( ) ; $ root = $ query -> in ( '' ) -> read ( ) -> whereHas ( $ this -> schema -> objectClass ( ) ) -> first ( ) ; if ( $ root ) { return ( new RootDse ( [ ] , $ query ) ) -> setRawAttributes ( $ root -> getAttributes ( ) ) ; } }
Returns the root DSE record .
42,457
public function compile ( Builder $ builder ) { $ ands = $ builder -> filters [ 'and' ] ; $ ors = $ builder -> filters [ 'or' ] ; $ raws = $ builder -> filters [ 'raw' ] ; $ query = $ this -> concatenate ( $ raws ) ; $ query = $ this -> compileWheres ( $ ands , $ query ) ; $ query = $ this -> compileOrWheres ( $ ors , ...
Compiles the Builder instance into an LDAP query string .
42,458
public function concatenate ( array $ bindings = [ ] ) { $ bindings = array_filter ( $ bindings , function ( $ value ) { return ( string ) $ value !== '' ; } ) ; return implode ( '' , $ bindings ) ; }
Concatenates filters into a single string .
42,459
public function compileStartsWith ( $ field , $ value ) { return $ this -> wrap ( $ field . Operator :: $ equals . $ value . Operator :: $ has ) ; }
Returns a query string for starts with .
42,460
public function compileEndsWith ( $ field , $ value ) { return $ this -> wrap ( $ field . Operator :: $ equals . Operator :: $ has . $ value ) ; }
Returns a query string for ends with .
42,461
public function initEventLogger ( ) { $ dispatcher = static :: getEventDispatcher ( ) ; $ logger = $ this -> newEventLogger ( ) ; $ dispatcher -> listen ( 'Adldap\Auth\Events\*' , function ( $ eventName , $ events ) use ( $ logger ) { foreach ( $ events as $ event ) { $ logger -> auth ( $ event ) ; } } ) ; $ dispatcher...
Initializes the event logger .
42,462
public function getValue ( ) { $ total = 0 ; foreach ( $ this -> values as $ value ) { $ total = $ total + $ value ; } return $ total ; }
Returns the complete account control value .
42,463
public function extractFlags ( $ flag ) { $ flags = [ ] ; for ( $ i = 0 ; $ i <= 26 ; $ i ++ ) { if ( ( int ) $ flag & ( 1 << $ i ) ) { array_push ( $ flags , 1 << $ i ) ; } } return $ flags ; }
Extracts the given flag into an array of flags used .
42,464
public function setValues ( array $ values = [ ] ) { $ this -> values = array_map ( function ( $ value ) { return ( string ) $ value ; } , $ values ) ; return $ this ; }
Sets the values of the modification .
42,465
public function setType ( $ type = null ) { if ( ! is_null ( $ type ) && ! $ this -> isValidType ( $ type ) ) { throw new InvalidArgumentException ( "Given batch modification type is invalid." ) ; } $ this -> type = $ type ; return $ this ; }
Sets the type of the modification .
42,466
public function build ( ) { $ filtered = array_diff ( array_map ( 'trim' , $ this -> values ) , [ '' ] ) ; if ( is_null ( $ this -> original ) ) { if ( ! empty ( $ filtered ) ) { $ this -> setType ( LDAP_MODIFY_BATCH_ADD ) ; } } else { if ( empty ( $ filtered ) ) { $ this -> setType ( LDAP_MODIFY_BATCH_REMOVE_ALL ) ; }...
Builds the type of modification automatically based on the current and original values .
42,467
public function get ( ) { switch ( $ this -> type ) { case LDAP_MODIFY_BATCH_REMOVE_ALL : return [ static :: KEY_ATTRIB => $ this -> attribute , static :: KEY_MODTYPE => $ this -> type ] ; case LDAP_MODIFY_BATCH_REMOVE : case LDAP_MODIFY_BATCH_ADD : case LDAP_MODIFY_BATCH_REPLACE : return [ static :: KEY_ATTRIB => $ th...
Returns the built batch modification array .
42,468
public function newBatchModification ( $ attribute = null , $ type = null , $ values = [ ] ) { return new BatchModification ( $ attribute , $ type , $ values ) ; }
Returns a new batch modification .
42,469
public function fresh ( ) { $ model = $ this -> query -> newInstance ( ) -> findByDn ( $ this -> getDn ( ) ) ; return $ model instanceof Model ? $ model : null ; }
Reload a fresh model instance from the directory .
42,470
public function syncRaw ( ) { if ( $ model = $ this -> fresh ( ) ) { $ this -> setRawAttributes ( $ model -> getAttributes ( ) ) ; return true ; } return false ; }
Synchronizes the current models attributes with the directory values .
42,471
public function addModification ( $ mod = [ ] ) { if ( $ mod instanceof BatchModification ) { $ mod = $ mod -> get ( ) ; } if ( $ this -> isValidModification ( $ mod ) ) { $ this -> modifications [ ] = $ mod ; return $ this ; } throw new InvalidArgumentException ( "The batch modification array does not include the mand...
Adds a batch modification to the models modifications array .
42,472
public function setDistinguishedName ( $ dn ) { $ this -> setFirstAttribute ( $ this -> schema -> distinguishedName ( ) , ( string ) $ dn ) ; return $ this ; }
Sets the model s distinguished name attribute .
42,473
public function getDnBuilder ( ) { $ dn = $ this -> getDistinguishedName ( ) ? : $ this -> query -> getDn ( ) ; return $ this -> getNewDnBuilder ( $ dn ) ; }
Returns a DistinguishedName object for modifying the current models DN .
42,474
public function getManagedByUser ( ) { if ( $ dn = $ this -> getManagedBy ( ) ) { return $ this -> query -> newInstance ( ) -> findByDn ( $ dn ) ; } return false ; }
Returns the user model of the user who is assigned to manage this object .
42,475
public function setManagedBy ( $ dn ) { if ( $ dn instanceof Model ) { $ dn = $ dn -> getDn ( ) ; } return $ this -> setFirstAttribute ( $ this -> schema -> managedBy ( ) , $ dn ) ; }
Sets the user who is assigned to managed this object .
42,476
public function inOu ( $ ou , $ strict = false ) { if ( $ ou instanceof Model ) { return ( bool ) strpos ( $ this -> getDn ( ) , $ ou -> getDn ( ) ) ; } $ suffix = $ strict ? '' : 'i' ; return ( bool ) preg_grep ( "/{$ou}/{$suffix}" , $ this -> getDnBuilder ( ) -> getComponents ( 'ou' ) ) ; }
Determine if the current model is located inside the given OU .
42,477
public function save ( array $ attributes = [ ] ) { $ this -> fireModelEvent ( new Events \ Saving ( $ this ) ) ; $ saved = $ this -> exists ? $ this -> update ( $ attributes ) : $ this -> create ( $ attributes ) ; if ( $ saved ) { $ this -> fireModelEvent ( new Events \ Saved ( $ this ) ) ; } return $ saved ; }
Saves the changes to LDAP and returns the results .
42,478
public function create ( array $ attributes = [ ] ) { $ this -> fill ( $ attributes ) ; if ( empty ( $ this -> getDn ( ) ) ) { $ dn = $ this -> getCreatableDn ( ) ; if ( $ dn -> get ( ) == $ this -> query -> getDn ( ) ) { throw new UnexpectedValueException ( "An LDAP object must have a valid RDN to be created. '$dn' gi...
Creates the entry in LDAP .
42,479
public function createAttribute ( $ attribute , $ value , $ sync = true ) { if ( $ this -> exists && $ this -> query -> getConnection ( ) -> modAdd ( $ this -> getDn ( ) , [ $ attribute => $ value ] ) ) { if ( $ sync ) { $ this -> syncRaw ( ) ; } return true ; } return false ; }
Creates an attribute on the current model .
42,480
public function updateAttribute ( $ attribute , $ value , $ sync = true ) { if ( $ this -> exists && $ this -> query -> getConnection ( ) -> modReplace ( $ this -> getDn ( ) , [ $ attribute => $ value ] ) ) { if ( $ sync ) { $ this -> syncRaw ( ) ; } return true ; } return false ; }
Updates the specified attribute with the specified value .
42,481
public function deleteAttribute ( $ attributes , $ sync = true ) { $ attributes = is_string ( $ attributes ) ? [ $ attributes => [ ] ] : $ attributes ; if ( $ this -> exists && $ this -> query -> getConnection ( ) -> modDelete ( $ this -> getDn ( ) , $ attributes ) ) { if ( $ sync ) { $ this -> syncRaw ( ) ; } return t...
Deletes an attribute on the current entry .
42,482
public function delete ( $ recursive = false ) { $ dn = $ this -> getDn ( ) ; if ( $ this -> exists === false || empty ( $ dn ) ) { throw ( new ModelDoesNotExistException ( ) ) -> setModel ( get_class ( $ this ) ) ; } $ this -> fireModelEvent ( new Events \ Deleting ( $ this ) ) ; if ( $ recursive ) { $ this -> newQuer...
Deletes the current entry .
42,483
public function move ( $ newParentDn , $ deleteOldRdn = true ) { $ parts = Utilities :: explodeDn ( $ this -> getDn ( ) , $ removeAttrPrefixes = false ) ; if ( ( int ) Arr :: first ( $ parts ) === 0 ) { throw new UnexpectedValueException ( "Current model does not contain an RDN to move." ) ; } $ rdn = Arr :: get ( $ pa...
Moves the current model into the given new parent .
42,484
public function rename ( $ rdn , $ newParentDn = null , $ deleteOldRdn = true ) { if ( $ newParentDn instanceof Model ) { $ newParentDn = $ newParentDn -> getDn ( ) ; } $ moved = $ this -> query -> getConnection ( ) -> rename ( $ this -> getDn ( ) , $ rdn , $ newParentDn , $ deleteOldRdn ) ; if ( $ moved ) { $ this -> ...
Renames the current model to a new RDN and new parent .
42,485
protected function isValidModification ( $ mod ) { return is_array ( $ mod ) && array_key_exists ( BatchModification :: KEY_MODTYPE , $ mod ) && array_key_exists ( BatchModification :: KEY_ATTRIB , $ mod ) ; }
Determines if the given modification is valid .
42,486
protected function buildModificationsFromDirty ( ) { foreach ( $ this -> getDirty ( ) as $ attribute => $ values ) { $ values = ( is_array ( $ values ) ? $ values : [ $ values ] ) ; $ modification = $ this -> newBatchModification ( $ attribute , null , $ values ) ; if ( array_key_exists ( $ attribute , $ this -> origin...
Builds the models modifications from its dirty attributes .
42,487
protected function convertStringToBool ( $ bool ) { $ bool = strtoupper ( $ bool ) ; if ( $ bool === strtoupper ( $ this -> schema -> false ( ) ) ) { return false ; } elseif ( $ bool === strtoupper ( $ this -> schema -> true ( ) ) ) { return true ; } else { return ; } }
Converts the inserted string boolean to a PHP boolean .
42,488
public function getIterator ( ) { $ entries = array_slice ( $ this -> getResults ( ) , $ this -> getCurrentOffset ( ) , $ this -> getPerPage ( ) , true ) ; return new ArrayIterator ( $ entries ) ; }
Get an iterator for the entries .
42,489
public static function explodeDn ( $ dn , $ removeAttributePrefixes = true ) { $ dn = ldap_explode_dn ( $ dn , ( $ removeAttributePrefixes ? 1 : 0 ) ) ; if ( is_array ( $ dn ) && array_key_exists ( 'count' , $ dn ) ) { foreach ( $ dn as $ rdn => $ value ) { $ dn [ $ rdn ] = self :: unescape ( $ value ) ; } } return $ d...
Converts a DN string into an array of RDNs .
42,490
public static function binarySidToString ( $ value ) { $ sid = @ unpack ( 'C1rev/C1count/x2/N1id' , $ value ) ; if ( ! isset ( $ sid [ 'id' ] ) || ! isset ( $ sid [ 'rev' ] ) ) { return ; } $ revisionLevel = $ sid [ 'rev' ] ; $ identifierAuthority = $ sid [ 'id' ] ; $ subs = isset ( $ sid [ 'count' ] ) ? $ sid [ 'count...
Convert a binary SID to a string SID .
42,491
public static function binaryGuidToString ( $ binGuid ) { if ( trim ( $ binGuid ) == '' || is_null ( $ binGuid ) ) { return ; } $ hex = unpack ( 'H*hex' , $ binGuid ) [ 'hex' ] ; $ hex1 = substr ( $ hex , - 26 , 2 ) . substr ( $ hex , - 28 , 2 ) . substr ( $ hex , - 30 , 2 ) . substr ( $ hex , - 32 , 2 ) ; $ hex2 = sub...
Convert a binary GUID to a string GUID .
42,492
public static function stringGuidToHex ( $ string ) { $ hex = '\\' . substr ( $ string , 6 , 2 ) . '\\' . substr ( $ string , 4 , 2 ) . '\\' . substr ( $ string , 2 , 2 ) . '\\' . substr ( $ string , 0 , 2 ) ; $ hex = $ hex . '\\' . substr ( $ string , 11 , 2 ) . '\\' . substr ( $ string , 9 , 2 ) ; $ hex = $ hex . '\\...
Converts a string GUID to it s hex variant .
42,493
public function auth ( AuthEvent $ event ) { if ( isset ( $ this -> logger ) ) { $ operation = get_class ( $ event ) ; $ connection = $ event -> getConnection ( ) ; $ message = "LDAP ({$connection->getHost()})" . " - Connection: {$connection->getName()}" . " - Operation: {$operation}" . " - Username: {$event->getUserna...
Logs an authentication event .
42,494
public function model ( ModelEvent $ event ) { if ( isset ( $ this -> logger ) ) { $ operation = get_class ( $ event ) ; $ model = $ event -> getModel ( ) ; $ on = get_class ( $ model ) ; $ connection = $ model -> getQuery ( ) -> getConnection ( ) ; $ message = "LDAP ({$connection->getHost()})" . " - Connection: {$conn...
Logs a model event .
42,495
public function getUserWorkstations ( ) { $ workstations = $ this -> getFirstAttribute ( $ this -> schema -> userWorkstations ( ) ) ; return array_filter ( explode ( ',' , $ workstations ) ) ; }
Returns an array of workstations the user is assigned to .
42,496
public function setUserWorkstations ( $ workstations = [ ] ) { if ( is_array ( $ workstations ) ) { $ workstations = implode ( ',' , $ workstations ) ; } return $ this -> setFirstAttribute ( $ this -> schema -> userWorkstations ( ) , $ workstations ) ; }
Sets the workstations the user can login to .
42,497
public function getBadPasswordDate ( ) { if ( $ timestamp = $ this -> getBadPasswordTimestamp ( ) ) { return ( new DateTime ( ) ) -> setTimestamp ( $ timestamp ) -> format ( $ this -> dateFormat ) ; } }
Returns the formatted timestamp of the bad password date .
42,498
public function getPasswordLastSetDate ( ) { if ( $ timestamp = $ this -> getPasswordLastSetTimestamp ( ) ) { return ( new DateTime ( ) ) -> setTimestamp ( $ timestamp ) -> format ( $ this -> dateFormat ) ; } }
Returns the formatted timestamp of the password last set date .
42,499
public function getLockoutDate ( ) { if ( $ timestamp = $ this -> getLockoutTimestamp ( ) ) { return ( new DateTime ( ) ) -> setTimestamp ( $ timestamp ) -> format ( $ this -> dateFormat ) ; } }
Returns the formatted timestamp of the lockout date .