- 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);
+ }