/** * Returns a new LDAP Entry instance. * * @param array $attributes * * @return Entry */ public function newLdapEntry(array $attributes = []) { $attribute = $this->schema->objectClass(); if (array_key_exists($attribute, $attributes) && array_key_exists(0, $attributes[$attribute])) { // Retrieve all of the object classes from the LDAP // entry and lowercase them for comparisons. $classes = array_map('strtolower', $attributes[$attribute]); // Retrieve the model mapping. $models = $this->map(); // Retrieve the object class mappings (with strtolower keys). $mappings = array_map('strtolower', array_keys($models)); // Retrieve the model from the map using the entry's object class. $map = array_intersect($mappings, $classes); if (count($map) > 0) { // Retrieve the objectclass attribute from the map. $class = current($map); // Retrieve the model from using the object class. $model = $models[$class]; // Construct and return a new model. return $this->newModel([], $model)->setRawAttributes($attributes); } } // A default entry model if the object category isn't found. return $this->newModel()->setRawAttributes($attributes); }
/** * Finds a record by its distinguished name. * * Fails upon no records returned. * * @param string $dn * @param array|string $columns * * @throws ModelNotFoundException * * @return bool|Entry */ public function findByDnOrFail($dn, $columns = []) { return $this->setDn($dn)->read(true)->whereHas($this->schema->objectClass())->firstOrFail($columns); }
/** * {@inheritdoc} */ public function getRootDse() { return $this->search()->setDn(null)->read(true)->whereHas($this->schema->objectClass())->first(); }
/** * Get the RootDSE properties from a domain controller. * * @return AbstractModel|bool */ protected function getRootDse() { return $this->query->setDn(null)->read(true)->whereHas($this->schema->objectClass())->first(); }
/** * Creates a new computer instance. * * @param array $attributes * * @return Computer */ public function computer(array $attributes = []) { return (new Computer($attributes, $this->query))->setAttribute($this->schema->objectClass(), [$this->schema->top(), $this->schema->person(), $this->schema->organizationalPerson(), $this->schema->user(), $this->schema->computer()]); }