|
@@ -2,7 +2,6 @@ package ldap
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "log"
|
|
|
"net/http"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
@@ -173,32 +172,3 @@ func (ldap *ldapHandler) SynchronizeUser(w http.ResponseWriter, r *http.Request)
|
|
|
}
|
|
|
common.SendOK(w)
|
|
|
}
|
|
|
-
|
|
|
-func (ldap *ldapHandler) NightlySync() {
|
|
|
- err := ldap.SynchronizeUserFromLDAP()
|
|
|
- log.Println(err)
|
|
|
-}
|
|
|
-
|
|
|
-func (ldap *ldapHandler) SynchronizeUserFromLDAP() error {
|
|
|
- //check if suer is admin before executing the command
|
|
|
- //if user is admin then check if user will lost him/her's admin access
|
|
|
- ldapUsersList, _, err := ldap.getAllUser(-1)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- for _, ldapUser := range ldapUsersList {
|
|
|
- //check if user exist in system
|
|
|
- if ldap.ag.UserExists(ldapUser.Username) {
|
|
|
- //if exists, then check if the user group is the same with ldap's setting
|
|
|
- //Get the permission groups by their ids
|
|
|
- userinfo, err := ldap.userHandler.GetUserInfoFromUsername(ldapUser.Username)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- newPermissionGroups := ldap.permissionHandler.GetPermissionGroupByNameList(ldapUser.EquivGroup)
|
|
|
- //Set the user's permission to these groups
|
|
|
- userinfo.SetUserPermissionGroup(newPermissionGroups)
|
|
|
- }
|
|
|
- }
|
|
|
- return nil
|
|
|
-}
|