Need to convert some VB6 code to C#

  • Thread starter Thread starter Mushq
  • Start date Start date
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
 
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
 
Back
Top