473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Remove user from local group

Hi,

I have the code snippet but it does not seem to work, could anyone point me out what wrong with it?

//try to remove a local user from a local group

string path = string.Format("WinNT://{0}/{1}/{2},group", domainName, serverName, groupName);

// Bind to remote computer Administrator group.
using (DirectoryEntry groupEntry = new DirectoryEntry(path))
{
path = string.Format("WinNT://{0}/{1}/{2},user", domainName, serverName, userName);
using (DirectoryEntry userEntry = new DirectoryEntry(path))
{
groupEntry.Children.Remove(userEntry);
}
}

I also find out that I could not cast the groupEntry to IADsgroup

string path = string.Format("WinNT://{0}/{1}/{2},group", domainName, serverName, groupName);

// Bind to remote computer Administrator group.
using (DirectoryEntry groupEntry = new DirectoryEntry(path))
{
IADsgroup grp = groupEntry as IADsgroup; //??? why the groupEntry cannot be cast to IADsgroup?


}

How can I add a domain group into a local group?

Thanks!
John
Jun 27 '08 #1
1 5215
Hi, John

I am interested in this issue. Would you mind letting me know the result of
my suggestions? If you need further assistance, please feel free to let me
know. I will be more than happy to be of assistance.

Have a great day!
Sincerely,
Zhi-Xin Ye
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
3
by: Ram | last post by:
Hey, I'v got a group in ActiveDirectory that has about 2000 members. I want to remove a certain user from that group. When I tried to remove it using the group's DirectoryEntry:...
3
by: Jiho Han | last post by:
Should ASPNET user belong to the local Users group? I may have made some changes that affected my workstation setup and I am experiencing some unexpected behaviors. For example, I have my IIS...
0
by: Terry Olsen | last post by:
Is there a way to remotely add/change/delete Local User/Group accounts remotely from VB.Net? We have a utility that would allow us to add a username to a local "netop" group on a PC. This then...
9
by: Sameh Ahmed | last post by:
Hello there Is there a way through dotNet to check if a certain user is a member of a specific group? I use ADSI to get the memberships of the user then compare them to the group I want to check,...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
1
by: orp | last post by:
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...
3
by: netzorro | last post by:
Hi all, I have an application and each user has a different db2 login user. For db2 I have to define the users on Windows OS (2003) Is there a way to disable those windows users but allow them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.