[Fwd: Re: Displaying a user's group memberships]

--------------070908020200010708080806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sorry, I sent these to the poster rather than the list--my bad.

-------- Original Message --------
Subject: 	Re: Displaying a user's group memberships
Date: 	Wed, 20 Dec 2006 20:23:53 -0700
From: 	Tom Smith <tom71713-perl@inqone.com>
To: 	John W. Krahn <krahnj@telus.net>
References: 	<45872961.7080805@inqone.com> 
<20061219001601.GA32475@apotheon.com> <4589B5BA.7060907@inqone.com> 
<4589E34E.60908@telus.net>



John W. Krahn wrote:
> Tom Smith wrote:
>   
>> Thank Chad (and John) for your input on this. I thought I'd post the
>> portion of the script that I was trying to work out to see if there's
>> room for improvement. This should work on any *nix system. The format of
>> the command is simple: `test.pl username`, where username is a real
>> username on the system in question. Here's the script:
>>
>> test.pl:
>> #!/usr/bin/env perl
>>
>> use strict;
>> use warnings;
>>
>> # Determine which Linux groups the user belongs to.
>> open(FILE,'</etc/group') or die "Can't open /etc/group.";
>>  
>> my @memberof;
>> while ($_ = <FILE>) {
>>        if($_ =~ /$ARGV[0]/) {
>>     
>
> Say that you have two users 'ron' and 'ronald'.  If $ARGV[0] contains 'ron'
> then this will get you the group names for *both* 'ron' *and* 'ronald' (and
> any other group names where the string 'ron' is found.)
>   

Good point... I hadn't thought of that. I'll look in to resolving it 
tomorrow (should be an easy fix, I would think :-) ).

>   
>>                my @groups = split(/:/,$_);
>>                push(@memberof,$groups[0]);
>>        }
>> }
>>
>> close FILE;
>>
>> print "\n@memberof\n\n";
>>
>>
>> So is there a better way to do this, or perhaps a cleaner way?
>>     
>
> Since you are only reading from /etc/group you are not picking up the primary
> group stored in /etc/passwd.
>   

I did think of that, but the primary group is still a group--even if 
it's the user's username. And thus it's listed in /etc/group. So I'm not 
sure that there's really an issue here--is there?

~ Tom

--------------070908020200010708080806--
0
tom71713
12/21/2006 2:47:28 PM
perl.beginners 29388 articles. 4 followers. Follow

0 Replies
464 Views

Similar Articles

[PageSpeed] 27
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

[Fwd: Re: Displaying a user's group memberships] #2
Sorry, I sent this to the poster rather than the list... My bad. -------- Original Message -------- Subject: Re: Displaying a user's group memberships Date: Wed, 20 Dec 2006 20:39:13 -0700 From: Tom Smith <tom71713-perl@inqone.com> To: John W. Krahn <krahnj@telus.net> References: <45872961.7080805@inqone.com> <20061219001601.GA32475@apotheon.com> <4589B5BA.7060907@inqone.com> <4589E34E.60908@telus.net> John W. Krahn wrote: > Tom Smith wrote: > >> Thank Chad (and John) for your input on this. I thought I'd pos...

Displaying a user's group memberships
I need to capture a user's group memberships for further processing in a Perl script. The user's username is passed to the script via the command line and captured with ARGV. From there, I want to determine the group memberships (much like executing `groups` from the command line) and run those through a loop for processing. I seem to be having a problem locating a function that will do this. I've looked at several and tried a couple, but either I'm doing something wrong or I'm using the wrong functions. All of the ones I've tried are part of getgr*. ...

Modifying user's group memberships using the System.DirectoryServices.Protocols (S.DS.P) Namespace
Hi everybody,I am connecting to an Active Directory server using the System.DirectoryServices.Protocols namespace (this is necessary as the AD server lives in a different, untrusted domain to the web server; and the ADSI security does not allow us to connect using the DirectoryEntry classes.)I am new to this namespace; but have made good progress recently. I can retrieve and modify user details, activate and deactivate their accounts, change their email address, telephone number, etc. and add new users into the directory. So I have got some familiarity with the classes and functionality whic...

changes made from one user's webpart's page, effects all user's
 I am just doing this offline right now in Visual Web Developer Express 2008I created the login inonce in the memberpage area, people can modify their webpart page. I created several users to test this out.  I loaded it in a browser.When I make changes as logged in user "A" .  Then logout and login as user "B", user "B,s" webpart page has been changed to user "A".This goes true for whomever I log in as.  It changes for everyone.Is there something specific I need to do in order to get everyone's changes to be unique for them...

Compare a Group's objectSid to a user's primaryGroupId
Dunnry, this question is related to my quest that you solved yesterday about how to get a primary group for a user. The difference is this time I try to a a list of users that are member of a given group.When using the member property to get a list of members of a given Group (e.g. GroupA), it didn't list those users whose primaryGroup is GroupA. So I am thinking to use a filter like (primaryGroupID= GroupA's Objectsid) when search users.However, the GroupA's objestSid is byte[] type, and the primaryGroupID is int type. Though the method in yesterday's post "CreatePrimaryGroupSID" ...

Impersonation: obtain the user's group membership
Hi, I have set up an ASP site which uses Impersonation, works fine. But I need to obtain the user's group membership somehow. Obtaining the Username is no Problem with Request.ServerVariables("LOGON_USER") (I'm using VBScript), but there is no variable for the user's groups. I read you can do it via ldap, and got folowing code: <% Set oConn = CreateObject("ADODB.Connection") Set oComm = CreateObject("ADODB.Command") oConn.Provider = "ADsDSOOBJECT" ' ADSI OLE-DB provider oConn.Open "ADs Provider" ...

Checking user's group membership with forms authentication
Hello all,I am writing a web site that uses forms authentication to check a user's credentials against our ldap server.  Since I am very inexperienced in asp.net, I used the tutorial found here for guidance.  I can now log in to the app, but find that I don't know how to check whether a user belongs to a group or not programmatically.  It seems it should be simple, but I cannot find it in the tutorial.Thanks in advance,WinterPhoenix check this: http://msdn.microsoft.com/en-us/library/ms998358.aspx/GuruBhai...

rights or attributes needed to modify a user's group membership
We have a container admin who can change passwords, login scripts, but I need him to modify a user's group membership. What righs does he need to the container that I'd like for him to administer? http://support.novell.com/cgi-bin/search/searchtid.cgi?/10064960.htm shanes_inbox@hotmail.com wrote: > We have a container admin who can change passwords, login scripts, but I > need him to modify a user's group membership. > > What righs does he need to the container that I'd like for him to > administer? -- Craig Wilson CNE3, 4, 5 - MCSE - CCNA...

determining a group's membership in other groups
Hi,   How can I determine if a certain Active Directory group is a member of other groups? Let’s say we have a group in Active Directory called ‘Microsoft Dallas Employees’ which contains the list of employees in Microsoft’s Dallas office. This group in turn belongs to a bigger group called Microsoft Employees. How do I use ‘Microsoft Dallas Employees’ as a search criteria and find out the other groups that this belongs to?   My environment is ASP.NET 2.0, C#, Active Dirtectory 2003 on  Windows server 2003   -Thanks   The easiest way would be to use an...

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

how to change a user's mailbox but keep the user's GW id
We have a user whose email has a space between her first name and middle name, which cause the problem in sending out email or receive email from the outside the network. Can someone advise how and where I suppose to change her email name to a valid name like firstname.middlename.lastname@xxx.com from firstname middle.lastname@xxx.com? Thank you very much! On Tue, 23 Oct 2007 15:27:51 +0000, April wrote: Duplicate. -- Joe Marton Novell Support Forum SysOp Novell does not officially monitor these forums! Use the Internet override - in ConsoleOne, GroupWise Tab, Inte...

login failed because user's IsApproved is false for user's account
Hi How can i detect if a user's login fails because their account is not approved yet (i.e IsApproved = false in Membership table) I am using a templated login control and if the user's login fails for this reason all that happens is that the FailureText control is displayed. How can i change the failure text if the user's account is not approved? thanks andrea Use Membership.GetUser Function this function Return a hydrated MembershipUser Object you can access its properties and check the validity see the link below http://msdn2.microsoft.com/en-us/library/40w5063z.aspxRega...

The 3.0.1 AD driver has a rule in the publisher command transform that strips unassociated users from groups so we don't affect eDir group membership that shouldn't be touched. The part that is faili
--____LEUBUQEWUFZXUVUONBYT____ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; modification-date="Fri, 27 Mar 2008 11:46:44 -0400" The 3.0.1 AD driver has a rule in the publisher command transform that = strips unassociated users from groups so we don't affect eDir group = membership that shouldn't be touched. The part that is failing (for some = reason) is near the end where we're checking to see if a user is unassociat= ed. The policy queries eDirectory with this: =20 token-xpath(&q...

Notes Driver: veto when user's fullname is the same as existing user's fullname
In the Notes Driver, I want to put the policy to veto when the current user's fullname is the same as existing user fullname is Lotus Domino Directory and and in eDirectory. How can I do the query to findout whether the user's fullname is the same as the existing ones or not. Please help.. Thanks Pattarawan. -- pattarawan pattarawan, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try one of the following op...

Web resources about - [Fwd: Re: Displaying a user's group memberships] - perl.beginners

The Church of Jesus Christ of Latter-day Saints membership statistics - Wikipedia, the free encyclopedia ...
Percentages of LDS members were calculated with this information. The link under the names of each country, territory, etc. corresponds to brief ...

Civility Caucus In Congress Turns To Facebook To Boost Membership
In the midst of a heated election season and record-low approval numbers for Congress, an under-the-radar congressional caucus focused on changing ...

Search Twitter - membership
... Bum @ prodigalbum 1m Nothing will consign Labour to oblivion faster than a backroom PLP coup to oust a leader chosen by the wider membership ...

Membership Has Its Privileges
Right now, crossing one of the magical rep borders happens more or less unnoticed. People just gain the particular powers. Now, of course they ...

Membership Cards - a set on Flickr
Sets let you organize your photos on Flickr. Explore the 1481 photos in this set.

Membership Sites Blueprint Review - The TRUTH Exposed! - YouTube
Membership Sites Blueprint review - http://www.cashandprofit.com/msb My FREE $1000 a day training - http://www.cashandprofit.com Hey guys its ...

The benefits of private club membership in the UAE
Lifestyle membership clubs can offer cardholders exclusive leisure discounts across the Emirates. But there can be a big catch - you need to ...

Sheikh's previous ALP membership revealed
ACT Greens senate candidate Simon Sheikh has conceded he was previously a member of the Labor party before becoming a self-proclaimed independent ...

Joe Tripodi's ALP membership suspended
NSW ALP has suspended membership of Joe Tripodi amid a corruption inquiry.

Arboretum membership gets flexible
Membership options for the National Arboretum have been expanded to include general and family passes.

Resources last updated: 12/5/2015 12:42:27 AM