getAttributes() public method

Get either: The attributes selected for a query operation. The attributes to be set for an add operation.
public getAttributes ( ) : array | null
return array | null
Ejemplo n.º 1
0
 /**
  * Builds the DN based off of the "name" attribute. The name attribute should be mapped to the "cn" attribute in
  * pretty much all cases except for creating an OU object. Then the "name" attribute should be mapped to "ou".
  *
  * @param AddOperation $operation
  */
 protected function setDnToUse(AddOperation $operation)
 {
     // If the DN was explicitly set, don't do anything.
     if ($operation->getDn()) {
         return;
     }
     if (!$this->schema) {
         throw new LogicException("You must explicitly set the DN or specify a schema type.");
     }
     if (!$this->schema->hasAttribute('name')) {
         throw new LogicException('To create an object you must specify the name attribute in the schema. That attribute should typically' . ' map to the "cn" attribute, as it will use that as the base of the distinguished name.');
     }
     $location = $operation->getLocation() ?: $this->schema->getDefaultContainer();
     if (empty($location)) {
         throw new LogicException('You must specify a container or OU to place this LDAP object in.');
     }
     $attribute = $this->schema->getAttributeToLdap('name');
     $rdnValue = LdapUtilities::escapeValue($operation->getAttributes()[$attribute], null, LDAP_ESCAPE_DN);
     $location = $this->resolveParameters(['container' => $location])['container'];
     $operation->setDn($attribute . '=' . $rdnValue . ',' . $location);
 }
Ejemplo n.º 2
0
 /**
  * Workaround AD special cases with the unicodePwd attribute...
  *
  * @link https://support.microsoft.com/en-us/kb/263991
  * @param AddOperation $operation
  */
 protected function unicodePwdHack(AddOperation $operation)
 {
     if (!$this->isUnicodePwdHackNeeded()) {
         return;
     }
     $attributes = $operation->getAttributes();
     foreach ($attributes as $attribute => $value) {
         if (strtolower($attribute) !== 'unicodepwd') {
             continue;
         }
         $value = is_array($value) ? reset($value) : $value;
         $attributes[$attribute] = base64_encode($value);
     }
     $operation->setAttributes($attributes);
 }