}
if (!$lc) return false;
-
+
ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($lc, LDAP_OPT_REFERRALS, 0);
if (defined('AUTH_DEBUG') && isTrue(AUTH_DEBUG)) {
ldap_set_option($lc, LDAP_OPT_DEBUG_LEVEL, 7);
}
-
+
// We need to handle Windows AD and OpenLDAP differently.
if ($this->params['type'] != 'openldap') {
-
+
// check if the user specified full login
if (strpos($login, '@') === false) {
// append default domain
}
$lb = @ldap_bind($lc, $login, $password);
-
+
if (defined('AUTH_DEBUG') && isTrue(AUTH_DEBUG)) {
echo '$lb='; var_dump($lb); echo '<br />';
echo 'ldap_error()='; echo ldap_error($lc); echo '<br />';
return false;
}
- if ($member_of) {
+ if ($member_of) {
// get groups
$filter = 'samaccountname='.Auth_ldap::ldap_escape($login);
ldap_unbind($lc);
- // handle special case - admin account, strip domain part
- if (strpos($login, 'admin@') !== false) {
- $login = substr($login, 0, 5);
- }
-
return array('login' => $login, 'data' => $entries, 'member_of' => $groups);
} else {
-
+
// Assuming OpenLDAP server.
$login_oldap = 'uid='.$login.','.$this->params['base_dn'];
if (defined('AUTH_DEBUG') && isTrue(AUTH_DEBUG)) {
echo '$login_oldap='; var_dump($login_oldap); echo '<br />';
}
-
+
// check if the user specified full login
if (strpos($login, '@') === false) {
// append default domain
}
$lb = @ldap_bind($lc, $login_oldap, $password);
-
+
if (defined('AUTH_DEBUG') && isTrue(AUTH_DEBUG)) {
echo '$lb='; var_dump($lb); echo '<br />';
echo 'ldap_error()='; echo ldap_error($lc); echo '<br />';
return false;
}
- if ($member_of) {
+ if ($member_of) {
// get groups
$filter = 'samaccountname='.Auth_ldap::ldap_escape($login_oldap);
ldap_unbind($lc);
- // handle special case - admin account, strip domain part
- if (strpos($login, 'admin@') !== false) {
- $login = substr($login, 0, 5);
- }
-
return array('login' => $login, 'data' => $entries, 'member_of' => $groups);
}
}
function isPasswordExternal() {
return true;
}
-}
\ No newline at end of file
+}
}
if ($request->isPost()) {
- $cl_password1 = $request->getParameter('password1');
- $cl_password2 = $request->getParameter('password2');
+ $cl_name = trim($request->getParameter('name'));
+ $cl_login = trim($request->getParameter('login'));
+ if (!$auth->isPasswordExternal()) {
+ $cl_password1 = $request->getParameter('password1');
+ $cl_password2 = $request->getParameter('password2');
+ }
+ $cl_email = trim($request->getParameter('email'));
+} else {
+ $cl_name = $user->name;
+ $cl_login = $user->login;
+ $cl_email = $user->email;
}
$form = new Form('optionsForm');
-$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password1','style'=>'width: 150px;','value'=>$cl_password1));
-$form->addInput(array('type'=>'text','aspassword'=>true,'maxlength'=>'30','name'=>'password2','style'=>"width: 150px;",'value'=>$cl_password2));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','value'=>$cl_name));
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'login','value'=>$cl_login));
+if (!$auth->isPasswordExternal()) {
+ $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password1','aspassword'=>true,'value'=>$cl_password1));
+ $form->addInput(array('type'=>'text','maxlength'=>'30','name'=>'password2','aspassword'=>true,'value'=>$cl_password2));
+}
+$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'=>$cl_email));
$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit')));
if ($request->isPost()) {
- if ($cl_password1 || $cl_password2) {
- // Validate user input.
+ // Validate user input.
+ if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name'));
+ if (!ttValidString($cl_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
+ // New login must be unique.
+ if ($cl_login != $user->login && ttUserHelper::getUserByLogin($cl_login))
+ $err->add($i18n->getKey('error.user_exists'));
+ if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) {
if (!ttValidString($cl_password1)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
if (!ttValidString($cl_password2)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
if ($cl_password1 !== $cl_password2)
$err->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
}
+ if (!ttValidEmail($cl_email, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+ // Finished validating user input.
- if ($err->no() && $cl_password1) {
- if (ttUserHelper::setPassword($user->id, $cl_password1)) {
+ if ($err->no()) {
+ if (ttUserHelper::update($user->id, array(
+ 'name' => $cl_name,
+ 'login' => $cl_login,
+ 'password' => $cl_password1,
+ 'email' => $cl_email,
+ 'status' => ACTIVE))) {
header('Location: admin_teams.php');
exit();
- } else
+ } else {
$err->add($i18n->getKey('error.db'));
+ }
}
} // isPost
+$smarty->assign('auth_external', $auth->isPasswordExternal());
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('title', $i18n->getKey('title.options'));
$smarty->assign('content_page_name', 'admin_options.tpl');