Need to convert some VB6 code to C#

M

Mushq

Hi,
I want to convert following VB6 code to C#, can some one help me
regarding that.

// Code starts here

strComputer = "atl-ws-01"

Set objGroup = GetObject("WinNT://" & strComputer & "/
Administrators")

For Each objUser In objGroup.Members
If objUser.Name <> "Administrator" AND objUser.Name <> "Domain
Admins" Then
objGroup.Remove(objUser.AdsPath)
End If
Next

// Code end here


actually it is removing users from Local administrator group.

or if some one knows how to delete users from local administrator
group in C#.

Thanks,
Mushq
 
M

Morten Wennevik [C# MVP]

Mushq said:
Hi,
I want to convert following VB6 code to C#, can some one help me
regarding that.

// Code starts here

strComputer = "atl-ws-01"

Set objGroup = GetObject("WinNT://" & strComputer & "/
Administrators")

For Each objUser In objGroup.Members
If objUser.Name <> "Administrator" AND objUser.Name <> "Domain
Admins" Then
objGroup.Remove(objUser.AdsPath)
End If
Next

// Code end here


actually it is removing users from Local administrator group.

or if some one knows how to delete users from local administrator
group in C#.

Thanks,
Mushq

Hi,

..Net comes with builtin support for Active Directory through
System.DirectoryServices. Add a reference to this dll in your project.

This article may prove helpful in manipulating group membership

[Programming With Groups]
http://msdn.microsoft.com/en-us/library/bb924542.aspx
 

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

Top