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

How get "log on locally" users and groups programatically?

P: n/a

Spent nearly 8 hours googling and trying code on this yesterday without much
success. I'd like to write a .NET application (using .NET primitives, older
Win32 calls, or WMI etc) to work out which users can log onto a machine the
application is running on. The platforms I'd like to support are
NT/2000/XP - although 98 would be good too.

It looks like for 2000 and XP OS' the answer is listed in the "Local
Security Policy" control panel application under the "Local Policies/User
Rights Assignment/Log on locally" policy. However, after trying a lot of
"GetObject("winmgmts:\\.\root") (or \RSOP\Computer or \root\SECURITY)" type
calls I'm no further in actually getting at the list the Local Security
Policy displays - I'm not even sure which winmgmts namespace I should be
looking in (as rsop doesn't exist on 2000 or below).

Can someone point me towards a solution for getting this list of users that
can log on? I'd like a solution which doesn't rely on domains (like a
standalone PC), although clearly if a machine is in a domain I need to
handle it. Also, is this policy really the definitive answer I should be
looking at or is there an alternative (esp. for older OS')?

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.