]> andersk Git - moira.git/commitdiff
Support fsgroups.
authorzacheiss <zacheiss>
Fri, 20 Jul 2001 21:15:31 +0000 (21:15 +0000)
committerzacheiss <zacheiss>
Fri, 20 Jul 2001 21:15:31 +0000 (21:15 +0000)
gen/winad.pc
incremental/winad/winad.c

index a0079912ce83501b4d53a918b9fa97aa983e828d..c6c07ab00d22c8dd607a6d9f070ae5bed1732ebf 100644 (file)
@@ -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;
index 3d45508a61796334f4240e649f4e99ac36f3bf64..4d886486d795e5e086606e67241a45379a00a79c 100755 (executable)
@@ -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;
This page took 0.156419 seconds and 5 git commands to generate.