Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Win32 Sample Code for checking if a user is in the group "Power Users" on a Windows (XP) machine?

by matze77 (Friar)
on Oct 23, 2009 at 15:49 UTC ( [id://802931]=perlquestion: print w/replies, xml ) Need Help??

matze77 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks!
How could i determine if a given user aka "Bob" (he is a member of the active directy domain) would be a "Power User" on a Windows XP machine .
(the german Term is "Hauptbenutzer" if i translated wrong ...).
Does someone have any useful sample code, which modules to use?.

Step B:
If this given user is not a "Power User" on the machine how could i add him to the (Local Machine Group) "Power Users"?
I have to use Something Like Win32::API:NET (LocalGroupGetMembers)? Would be really kind if someone got a little sample code wich i could modify for my needs ...

Thanks in Advance MH

Replies are listed 'Best First'.
Re: Win32 Sample Code for checking if a user is in the group "Power Users" on a Windows (XP) machine? (Win32API::Net)
by tye (Sage) on Oct 24, 2009 at 12:11 UTC

    I'd use Win32API::Net. No, I'm not going to construct "an example". The task is simple enough you should be able to read the documentation and put together your desired script pretty easily (you might need to read a little bit about programming in Perl as well, depending, but if so, that would be a good thing for you to do anyway).

    If you have difficulties getting it to work, then come back and post an example for us of what you tried and exactly how it isn't working for you.

    - tye        

Re: Win32 Sample Code for checking if a user is in the group "Power Users" on a Windows (XP) machine?
by romandas (Pilgrim) on Oct 24, 2009 at 17:08 UTC

    An additional module you can use is Win32::OLE for tapping into the Windows Management Interface (WMI).

    As for providing sample code.. it wouldn't be very kind of you to ask for code without providing some of your own first. Might I suggest using a search engine, such as Google, to search for the terms 'perl', 'wmi', and 'groups'. There are tons of examples out there.

    If you're really stuck, check out Microsoft's Scriptomatic. It can create the code you're looking for, and will even do it in Perl!

Re: Win32 Sample Code for checking if a user is in the group "Power Users" on a Windows (XP) machine?
by goibhniu (Hermit) on Oct 26, 2009 at 19:16 UTC

    a TIMTOWDI suggestion:

    c:\>net localgroup "Power Users"

    produces a list of user who are a member of that localgroup on my system. Perhaps you could parse the output?


    #my sig used to say 'I humbly seek wisdom. '. Now it says:
    use strict;
    use warnings;
    I humbly seek wisdom.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://802931]
Approved by wfsp
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found