By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & Developers. It's quick & easy.

verify a user

P: n/a
If I have a unix user name, is there a way to verify that the user really
exists and query default group memberships?

--
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
Jan 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 18 Jan 2006 18:25:19 -0700,
David Bear <da********@asu.edu> wrote:
If I have a unix user name, is there a way to verify that the user
really exists and query default group memberships?


import pwd
unix_user_name = raw_input( 'enter a user name:' )
try:
print pwd.getpwnam( unix_user_name )
except KeyError:
print unix_user_name, 'does not exist'

There's a grp module for making similar queries against /etc/group (or
the modern equivalent thereof).

Regards,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
Jan 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.