From dev-return-23632-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Dec 10 04:10:07 2010 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 82256 invoked from network); 10 Dec 2010 04:10:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Dec 2010 04:10:07 -0000 Received: (qmail 85826 invoked by uid 500); 10 Dec 2010 04:10:06 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 85422 invoked by uid 500); 10 Dec 2010 04:10:03 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 85414 invoked by uid 99); 10 Dec 2010 04:10:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Dec 2010 04:10:02 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [64.202.165.29] (HELO smtpauth17.prod.mesa1.secureserver.net) (64.202.165.29) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 10 Dec 2010 04:09:53 +0000 Received: (qmail 9699 invoked from network); 10 Dec 2010 03:54:28 -0000 Received: from unknown (76.252.112.72) by smtpauth17.prod.mesa1.secureserver.net (64.202.165.29) with ESMTP; 10 Dec 2010 03:54:28 -0000 Message-ID: <4D01A7F0.7090503@rowe-clan.net> Date: Thu, 09 Dec 2010 22:09:20 -0600 From: "William A. Rowe Jr." User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: dev@apr.apache.org Subject: Re: Getting the groups a user belongs to References: <4D019264.3090606@gmail.com> In-Reply-To: <4D019264.3090606@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 12/9/2010 8:37 PM, William R Speirs wrote: > I was looking through the APR and noticed that no function exists to get the groups (gid > or char*) that a user belongs to. > > I started investigating how to implement such a thing on Unix/Linux and it doesn't seem > hard; getgrouplist will return a gid list given a user. > > On Windows things are bit more tricky because the computer can either be a member of a > domain, or on its own. I think the following basic flow will work, but I'd like a second > opinion: > > - Call GetNetworkParams to see if there is a domain name > - If no domain name, then call NetUserGetLocalGroups > - If there is a domain name, then call NetUserGetGroups It seems sensible, the only hassle is the performance penalty that could be assessed for hitting the domain server. Can you check this out and benchmark it? > The other issue is that on Windows I get back a char* for the groups; whereas, on > Unix/Linux I get back a gid list. Is there a preference? Would people rather a function > that returns a gid list or a char* list? Well, we should treat them as apr_gid_t, which on win32 would devolve to a pointer to a full UUID of the appropriate group (and we then unwind the identifier into a human-readable string with the appropriate apr_group_name_get function). APR 2.0 is open for business, patches for enhancements are most welcome!