/** * Get a user's distinguished name by attempting to replace the username keyword * in the query. Supports multiple distinguished names in a list. * * @param string $username Authenticating username. * * @return array An array containing distinguished names. * * @since 1.0 * @throws InvalidArgumentException Invalid argument in config related error */ public function getUserDnDirectly($username) { $return = array(); // Fixes special usernames and provides protection against distinguished name injection $username = SHLdapHelper::escape($username, true); // Replace the username placeholder with the authenticating username $search = str_replace(self::USERNAME_REPLACE, $username, $this->user_qry); // Splits each of the distinguished names into indivdual elements $DNs = explode(';', $search); // We need to find the correct distinguished name from the set of elements foreach ($DNs as $dn) { // Remove whitespacing from the distinguished name and check there is a length > 1 if ($dn = trim($dn)) { $return[] = $dn; } } return $return; }
/** * Returns the distinguished name. * * @param array $form Registration form. * * @return string Distinguished name. * * @since 2.0 */ public function getMandatoryDN($form) { $name = SHLdapHelper::escape($form['name'], true); return "CN={$name},OU=People,DC=shmanic,DC=net"; }
/** * Returns the distinguished name. * * @param array $form Registration form. * * @return string Distinguished name. * * @since 2.0 */ public function getMandatoryDN($form) { $username = SHLdapHelper::escape($form['username'], true); return "uid={$username},ou=People,dc=shmanic,dc=net"; }