Пример #1
0
 /**
  * Returns count of users in LDAP that are member of a specific group of names. Uses a search
  * filter with memberof=?.
  *
  * @param string $memberOf The group to check.
  * @return int
  * @throws Exception if the current user is not a Super User or something goes wrong with LDAP.
  */
 public function getCountOfUsersMemberOf($memberOf)
 {
     Piwik::checkUserHasSuperUserAccess();
     $memberOf = Common::unsanitizeInputValue($memberOf);
     $memberOfField = Config::getRequiredMemberOfField();
     return $this->ldapUsers->getCountOfUsersMatchingFilter("(" . $memberOfField . "=?)", array($memberOf));
 }
Пример #2
0
 /**
  * Creates a new {@link LdapUsers} instance using config.ini.php values.
  *
  * @return LdapUsers
  */
 public static function makeConfigured()
 {
     $result = new LdapUsers();
     $result->setLdapServers(Config::getConfiguredLdapServers());
     $usernameSuffix = Config::getLdapUserEmailSuffix();
     if (!empty($usernameSuffix)) {
         $result->setAuthenticationUsernameSuffix($usernameSuffix);
     }
     $requiredMemberOf = Config::getRequiredMemberOf();
     if (!empty($requiredMemberOf)) {
         $result->setAuthenticationRequiredMemberOf($requiredMemberOf);
     }
     $memberOfField = Config::getRequiredMemberOfField();
     if (!empty($memberOfField)) {
         $result->setAuthenticationMemberOfField($memberOfField);
     }
     $filter = Config::getLdapUserFilter();
     if (!empty($filter)) {
         $result->setAuthenticationLdapFilter($filter);
     }
     $timeoutSecs = Config::getLdapNetworkTimeout();
     if (!empty($timeoutSecs)) {
         $result->setLdapNetworkTimeout($timeoutSecs);
     }
     $result->setLdapUserMapper(UserMapper::makeConfigured());
     Log::debug("LdapUsers::%s: configuring with userEmailSuffix = %s, requiredMemberOf = %s, filter = %s, timeoutSecs = %s", __FUNCTION__, $usernameSuffix, $requiredMemberOf, $filter, $timeoutSecs);
     return $result;
 }
Пример #3
0
 /**
  * Creates a new {@link LdapUsers} instance using config.ini.php values.
  *
  * @return LdapUsers
  */
 public static function makeConfigured()
 {
     $result = new LdapUsers();
     $result->setLdapServers(Config::getConfiguredLdapServers());
     $usernameSuffix = Config::getLdapUserEmailSuffix();
     if (!empty($usernameSuffix)) {
         $result->setAuthenticationUsernameSuffix($usernameSuffix);
     }
     $requiredMemberOf = Config::getRequiredMemberOf();
     if (!empty($requiredMemberOf)) {
         $result->setAuthenticationRequiredMemberOf($requiredMemberOf);
     }
     $memberOfField = Config::getRequiredMemberOfField();
     if (!empty($memberOfField)) {
         $result->setAuthenticationMemberOfField($memberOfField);
     }
     $filter = Config::getLdapUserFilter();
     if (!empty($filter)) {
         $result->setAuthenticationLdapFilter($filter);
     }
     $timeoutSecs = Config::getLdapNetworkTimeout();
     if (!empty($timeoutSecs)) {
         $result->setLdapNetworkTimeout($timeoutSecs);
     }
     $result->setLdapUserMapper(UserMapper::makeConfigured());
     return $result;
 }