1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

Update ldap system

This commit is contained in:
Kay0u 2020-03-27 02:24:24 +01:00
parent 00bf20aa02
commit 5b4b0f2ca4
No known key found for this signature in database
GPG key ID: 7FF262C033518333
3 changed files with 26 additions and 25 deletions

View file

@ -26,28 +26,27 @@ class myDcAuth extends dcAuth
# Store the password # Store the password
$cur->user_pwd = $pwd; $cur->user_pwd = $pwd;
# If the user exist, then we just update his password. # search the user in ldap, and get infos
if ($this->core->userExists($user_id)) $filter="(&(|(objectclass=posixAccount))(uid=".$user_id.")(permission=cn=__APP__.admin,ou=permission,dc=yunohost,dc=org))";
{ $sr=ldap_search($ds,$racine, $filter, array("dn", "cn", "sn", "mail", "givenname")); # /!\ fields have to be in lowercase
$this->sudo(array($this->core,'updUser'),$user_id,$cur); $info = ldap_get_entries($ds, $sr);
$this->con->commit();
}
# If not, we create him.
# In order for him to connect,
# it is necessary to give him at least
# a permission "usage" on the blog "default".
else
{
# search the user in ldap, and get infos
$sr=ldap_search($ds,$racine,"uid=$user_id",array( "dn", "cn", "sn", "mail", "givenname")); # /!\ fields have to be in lowercase
$info = ldap_get_entries($ds, $sr);
if ($info["count"] == 1)
if ($info["count"] ==1) {
{ # If the user exist, then we just update his password.
$cur->user_id = $user_id; if ($this->core->userExists($user_id))
$cur->user_email = $info[0]['mail'][0]; {
$cur->user_name = $info[0]['givenname'][0]; $this->sudo(array($this->core,'updUser'),$user_id,$cur);
}
# If not, we create him.
# In order for him to connect,
# it is necessary to give him at least
# a permission "usage" on the blog "default".
else
{
$cur->user_id = $user_id;
$cur->user_email = $info[0]['mail'][0];
$cur->user_name = $info[0]['givenname'][0];
$cur->user_firstname = $info[0]['sn'][0]; $cur->user_firstname = $info[0]['sn'][0];
$cur->user_lang = 'fr'; # Can change this, PR are welcome $cur->user_lang = 'fr'; # Can change this, PR are welcome
$cur->user_tz = 'Europe/Paris'; # Can change this, PR are welcome $cur->user_tz = 'Europe/Paris'; # Can change this, PR are welcome
@ -65,9 +64,9 @@ class myDcAuth extends dcAuth
#pages "manage pages" #pages "manage pages"
#blogroll "manage blogroll" #blogroll "manage blogroll"
$this->sudo(array($this->core,'setUserBlogPermissions'),$user_id,'default',array('usage'=>true)); # Can change this, PR are welcome $this->sudo(array($this->core,'setUserBlogPermissions'),$user_id,'default',array('usage'=>true)); # Can change this, PR are welcome
$this->con->commit(); }
} $this->con->commit();
} }
# The previous operations proceeded without error, # The previous operations proceeded without error,
# we can now call the parent method # we can now call the parent method

View file

@ -113,6 +113,7 @@ password=$(ynh_string_random 30)
cp $php_config.in $php_config cp $php_config.in $php_config
cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php
ynh_replace_string "__APP__" "$app" $final_path/inc/class.auth.ldap.php
admin_url=$(ynh_url_join $path_url admin/index.php) admin_url=$(ynh_url_join $path_url admin/index.php)

View file

@ -152,6 +152,7 @@ ynh_add_fpm_config
cp $php_config.in $php_config cp $php_config.in $php_config
cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php
ynh_replace_string "__APP__" "$app" $final_path/inc/class.auth.ldap.php
firstname=$(yunohost user info $admin | grep firstname: | cut -d' ' -f2 | tr -d '\n') firstname=$(yunohost user info $admin | grep firstname: | cut -d' ' -f2 | tr -d '\n')
lastname=$(yunohost user info $admin | grep lastname: | cut -d' ' -f2 | tr -d '\n') lastname=$(yunohost user info $admin | grep lastname: | cut -d' ' -f2 | tr -d '\n')