--------------------- PatchSet 6234 Date: 2004/06/24 17:39:16 Author: serassio Branch: nt-2_5 Tag: (none) Log: Fixed another problem in win32_check_group with trusted domains and Windows NT 4 compatibility Members: helpers/external_acl/win32_group/win32_check_group.c:1.1.8.13->1.1.8.14 Index: squid/helpers/external_acl/win32_group/win32_check_group.c =================================================================== RCS file: /cvsroot/squid-sf//squid/helpers/external_acl/win32_group/Attic/win32_check_group.c,v retrieving revision 1.1.8.13 retrieving revision 1.1.8.14 diff -u -r1.1.8.13 -r1.1.8.14 --- squid/helpers/external_acl/win32_group/win32_check_group.c 12 Jun 2004 19:49:26 -0000 1.1.8.13 +++ squid/helpers/external_acl/win32_group/win32_check_group.c 24 Jun 2004 17:39:16 -0000 1.1.8.14 @@ -366,7 +366,9 @@ strlwr(NTDomain); } -/* Convert ANSI User Name and Group to Unicode */ + debug("Valid_Global_Groups: checking group membership of '%s\\%s'.\n", NTDomain, User); + + /* Convert ANSI User Name and Group to Unicode */ MultiByteToWideChar(CP_ACP, 0, User, strlen(User) + 1, wszUserName, @@ -385,41 +387,45 @@ if ((pSrvBuf->sv101_type & SV_TYPE_DOMAIN_CTRL) || (pSrvBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL)) { - nStatus = NetApiBufferAllocate(sizeof(pSrvBuf->sv101_name), (LPVOID *) &LclDCptr); - wcscpy(LclDCptr, (PCWSTR) pSrvBuf->sv101_name); + LclDCptr = NULL; + debug("Running on a DC.\n"); } else nStatus = NetGetAnyDCName(NULL, wszLocalDomain, (LPBYTE *) & LclDCptr); + } else { + fprintf(stderr, "%s NetServerGetInfo() failed.'\n", myname); + if (pSrvBuf != NULL) + NetApiBufferFree(pSrvBuf); + return result; } if (nStatus == NERR_Success) { - if (strcmp(NTDomain, machinedomain) != 0) { + debug("Using '%S' as DC for '%S' local domain.\n", LclDCptr, wszLocalDomain); + + if (strcmp(NTDomain, machinedomain) != 0) { MultiByteToWideChar(CP_ACP, 0, NTDomain, strlen(NTDomain) + 1, wszUserDomain, sizeof(wszUserDomain) / sizeof(wszUserDomain[0])); - nStatus = NetGetAnyDCName( - LclDCptr, - wszUserDomain, - (LPBYTE *) & UsrDCptr); - if (nStatus != NERR_Success) { - fprintf(stderr, "%s Can't find DC for domain %s\n", myname, NTDomain); - if (pSrvBuf != NULL) - NetApiBufferFree(pSrvBuf); - if (LclDCptr != NULL) - NetApiBufferFree((LPVOID) LclDCptr); - if (UsrDCptr != NULL) - NetApiBufferFree((LPVOID) UsrDCptr); - return result; - } + nStatus = NetGetAnyDCName( + LclDCptr, + wszUserDomain, + (LPBYTE *) & UsrDCptr); + if (nStatus != NERR_Success) { + fprintf(stderr, "%s Can't find DC for user's domain '%s'\n", myname, NTDomain); + if (pSrvBuf != NULL) + NetApiBufferFree(pSrvBuf); + if (LclDCptr != NULL) + NetApiBufferFree((LPVOID) LclDCptr); + if (UsrDCptr != NULL) + NetApiBufferFree((LPVOID) UsrDCptr); + return result; + } } else UsrDCptr = LclDCptr; + debug("Using '%S' as DC for '%s' user's domain.\n", UsrDCptr, NTDomain); /* - * Call the NetUserGetLocalGroups function + * Call the NetUserGetGroups function * specifying information level 0. - * - * The LG_INCLUDE_INDIRECT flag specifies that the - * function should also return the names of the local - * groups in which the user is indirectly a member. */ dwLevel = 0; nStatus = NetUserGetGroups(UsrDCptr, @@ -448,10 +454,12 @@ dwTotalCount++; } } - } else - result = 0; + } else { + result = 0; + fprintf(stderr, "%s NetUserGetGroups() failed.'\n", myname); + } } else { - fprintf(stderr, "%s Can't find DC for domain %s\n", myname, machinedomain); + fprintf(stderr, "%s Can't find DC for local domain '%s'\n", myname, machinedomain); } /* * Free the allocated memory.