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

Determine if Local User is in Local Group

P: n/a
orp
We've been struggling on how to determine if a local user is already in a
local group. We have code (C#) that creates a local user, if the user
doesn't already exist. And, we have code (C#) that creates a local group,
if the group doesn't already exist. Both of these work fine.

Now, we need to check whether the local user is already in the local group
or not. We have code (C#) that adds the local user to the local group, but
we cannot get any code to work to first determine if the local user is
already in the local group (because if the local user is already in the
local group, we don't want to try to add them).

Would anyone know how to determine if a local user is in a local group?
Apr 10 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello, orp!

o> Now, we need to check whether the local user is already in the local
o> group or not. We have code (C#) that adds the local user to the local
o> group, but we cannot get any code to work to first determine if the
o> local user is already in the local group (because if the local user is
o> already in the local group, we don't want to try to add them).

How do you, add users to the local group. I mean what API do you use?
If you use network management api ( located in netapi32.dll ),
then you can utilize NetLocalGroupGetMembers function.

Take a look at following URL
( http://www.codeproject.com/csharp/groupandmembers.asp )

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.