Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - deleted

Pages: [1]
1
Pусский / Re: Установка FO 2.0 Beta
« on: September 28, 2011, 09:12:02 am »
Замени префикс таблиц

2
много танцев с бубном. нужно добавлять поле и сильно ковырять код. соответственно при апгрейде все слетит

3
Pусский / Re: Проблемы с почтой
« on: March 15, 2011, 04:33:44 am »
У меня вообще не добавляет почтовые аккаунты... Как справились?
Через POP - работает IMAP - висит

4
Installation problems / Re: Auto create user from LDAP [SOLVED]
« on: February 10, 2011, 05:13:43 am »
Find bug:
When created personal project, P1 field = 0.
Need help. How create correct personal project?

5
Installation problems / Auto create user from LDAP [SOLVED]
« on: January 31, 2011, 06:44:38 am »
Create function in \fengoffice\application\models\users\User.class.php

Code: [Select]
/**
* Get user attributes from ldap
*
* @return attribute value
*/
function AttribFromLdap($user, $password, $config, $attrib) {

// Connecting using the configuration:
require_once "Net/LDAP2.php";

$ldap = Net_LDAP2::connect($config);

// Testing for connection error
if (PEAR::isError($ldap)) {
return false;
}
$filter = Net_LDAP2_Filter::create($config['uid'], 'equals', $user);
$search = $ldap->search(null, $filter, array());

if (Net_LDAP2::isError($search)) {
return false;
}

if ($search->count() != 1) {
return false;
}

// User exists so we may rebind to authenticate the password
$entries = $search->entries();
$result = $entries[0]->getValue($attrib);

return $result;
} // AttribFromLdap


Change \fengoffice\application\controllers\AccessController.class.php in section // If ldap authentication is enabled ldap.config.php will return true.
Code: [Select]
// If ldap authentication is enabled ldap.config.php will return true.
$config_ldap_file_path = ROOT . '/config/ldap.config.php';
$config_ldap_is_set = file_exists($config_ldap_file_path) && include_once($config_ldap_file_path);

  // create temp object and check LDAP
$temp_user = new User();
$temp_user->setCompanyId(1);
$temp_user->setUsername($username);
$temp_user->setPassword($password);
$userIsValidPassword = $temp_user->isValidPasswordLdap($username, $password, $config_ldap); // Check password

if ($userIsValidPassword && !($user instanceof User)) { //If user found in LDAP and not registered then save user and set properties

$temp_user->setEmail($temp_user->AttribFromLdap($username, $password, $config_ldap, "mail")); // Use custom function. \fengoffice\application\models\users\User.class.php
$temp_user->setDisplayName($temp_user->AttribFromLdap($username, $password, $config_ldap, "cn"));

$temp_user->save();

$user = $temp_user;

$project = new Project();
$project->setName(new_personal_project_name($user->getDisplayName())); // set Project name. For exemple $user->getUsername()
$project->setDescription(lang('files'));
$project->setCreatedById($user->getId());

$project->save();

$user->setPersonalProjectId($project->getId()); // set default project

$project_user = new ProjectUser();
$project_user->setProjectId($project->getId());
$project_user->setUserId($user->getId());
$project_user->setCreatedById($user->getId());
$project_user->setAllPermissions(true);

$project_user->save();
}

if(!($user instanceof User)) {
AdministrationLogs::createLog("invalid login", array_var($_SERVER, 'REMOTE_ADDR'), AdministrationLogs::ADM_LOG_CATEGORY_SECURITY);
tpl_assign('error', new Error(lang('invalid login data')));
$this->render();
} // if

Working!

Pages: [1]