]> andersk Git - moira.git/blobdiff - incremental/winad/winad.c
Support fsgroups.
[moira.git] / incremental / winad / winad.c
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.578014 seconds and 4 git commands to generate.