Determine if Local User is in Local Group

  • Thread starter Thread starter orp
  • Start date Start date
O

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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top