From 65382c4673bc745a1866718d3e6ab16d8dbb46ca Mon Sep 17 00:00:00 2001 From: zacheiss Date: Fri, 20 Jul 2001 21:15:31 +0000 Subject: [PATCH] Support fsgroups. --- gen/winad.pc | 63 +++++++++++++++++++++++++++++++-------- incremental/winad/winad.c | 47 +++++++++++++++++++++-------- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/gen/winad.pc b/gen/winad.pc index a0079912..c6c07ab0 100644 --- a/gen/winad.pc +++ b/gen/winad.pc @@ -84,6 +84,7 @@ int do_user(void) int users_id, unix_uid, status; char type[FILESYS_TYPE_SIZE]; char name[FILESYS_NAME_SIZE]; + int fid; EXEC SQL END DECLARE SECTION; sprintf(foutf, "%s/winuser.db", winad_dir); @@ -110,26 +111,64 @@ int do_user(void) strtrim(login); strtrim(mit_id); - EXEC SQL SELECT type, name INTO :type, :name - FROM filesys - WHERE lockertype = 'HOMEDIR' - AND owner = :users_id; + EXEC SQL SELECT filsys_id into :fid + FROM filesys + WHERE lockertype = 'HOMEDIR' + AND label = :login + AND type = 'FSGROUP'; if (sqlca.sqlcode == 0) { - strtrim(type); - strtrim(name); + EXEC SQL DECLARE f_cursor CURSOR FOR + SELECT type, name + FROM filesys a, fsgroup b + WHERE a.filsys_id=b.filsys_id + AND b.group_id=:fid + ORDER by key; + + EXEC SQL OPEN f_cursor; + + EXEC SQL FETCH f_cursor INTO :type, :name; + + if (sqlca.sqlcode == 0) + { + strtrim(type); + strtrim(name); + } + else + { + strcpy(type, ""); + strcpy(name, ""); + } + + EXEC SQL CLOSE f_cursor; } + + else { - strcpy(type, ""); - strcpy(name, ""); + EXEC SQL SELECT type, name into :type, :name + FROM filesys + WHERE lockertype = 'HOMEDIR' + AND label=:login; + + if (sqlca.sqlcode == 0) + { + strtrim(type); + strtrim(name); + } + else + { + strcpy(type, ""); + strcpy(name, ""); + } } + fprintf(fout, "%d %s %d %d %s %s %s\n", - users_id, login, unix_uid, status, mit_id, - type, name); - } - + users_id, login, unix_uid, status, mit_id, + type, name); + } + if (sqlca.sqlcode < 0) db_error(sqlca.sqlcode); EXEC SQL CLOSE u_cursor; diff --git a/incremental/winad/winad.c b/incremental/winad/winad.c index 3d45508a..4d886486 100755 --- a/incremental/winad/winad.c +++ b/incremental/winad/winad.c @@ -2285,11 +2285,14 @@ int user_update(LDAP *ldap_handle, char *dn_path, char *user_name, int n; int rc; int i; + int last_weight; u_int userAccountControl = UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD | UF_PASSWD_CANT_CHANGE; char filter[128]; char *attr_array[3]; + char cWeight[3]; char **hp; char path[256]; + char cPath[256]; char temp[256]; char winPath[256]; char winProfile[256]; @@ -2348,20 +2351,40 @@ int user_update(LDAP *ldap_handle, char *dn_path, char *user_name, n = 0; if ((hp = hes_resolve(user_name, "filsys")) != NULL) { + memset(cWeight, 0, sizeof(cWeight)); + memset(cPath, 0, sizeof(cPath)); memset(path, 0, sizeof(path)); memset(winPath, 0, sizeof(winPath)); - sscanf(hp[0], "%*s %s", path); - if (strlen(path) && strnicmp(path, AFS, strlen(AFS)) == 0) - { - AfsToWinAfs(path, winPath); - homedir_v[0] = winPath; - ADD_ATTR("homeDirectory", homedir_v, LDAP_MOD_REPLACE); - strcpy(winProfile, winPath); - strcat(winProfile, "\\.winprofile"); - winProfile_v[0] = winProfile; - ADD_ATTR("profilePath", winProfile_v, LDAP_MOD_REPLACE); - drives_v[0] = "H:"; - ADD_ATTR("homeDrive", drives_v, LDAP_MOD_REPLACE); + last_weight = 1000; + i = 0; + while (hp[i] != NULL) + { + sscanf(hp[i], "%*s %s", cPath); + if (strlen(cPath) && strnicmp(cPath, AFS, strlen(AFS)) == 0) + { + sscanf(hp[i], "%*s %*s %*s %*s %s", cWeight); + if (atoi(cWeight) < last_weight) + { + strcpy(path, cPath); + last_weight = (int)atoi(cWeight); + } + } + ++i; + } + if (strlen(path)) + { + if (!strnicmp(path, AFS, strlen(AFS))) + { + AfsToWinAfs(path, winPath); + homedir_v[0] = winPath; + ADD_ATTR("homeDirectory", homedir_v, LDAP_MOD_REPLACE); + strcpy(winProfile, winPath); + strcat(winProfile, "\\.winprofile"); + winProfile_v[0] = winProfile; + ADD_ATTR("profilePath", winProfile_v, LDAP_MOD_REPLACE); + drives_v[0] = "H:"; + ADD_ATTR("homeDrive", drives_v, LDAP_MOD_REPLACE); + } } } uid_v[0] = Uid; -- 2.45.2