Click here to Skip to main content
15,915,759 members
Home / Discussions / C#
   

C#

 
AnswerRe: vb.net to c#.net Pin
Pravin Patil, Mumbai23-Feb-11 23:49
Pravin Patil, Mumbai23-Feb-11 23:49 
QuestionQuestion about adding/removing account Pin
turbosupramk323-Feb-11 9:05
turbosupramk323-Feb-11 9:05 
AnswerRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 9:42
GenJerDan23-Feb-11 9:42 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 10:14
turbosupramk323-Feb-11 10:14 
GeneralRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 10:38
GenJerDan23-Feb-11 10:38 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:05
turbosupramk323-Feb-11 11:05 
GeneralRe: Question about adding/removing account Pin
GenJerDan23-Feb-11 11:08
GenJerDan23-Feb-11 11:08 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:33
turbosupramk323-Feb-11 11:33 
Here is what I found that will work, with this code you can successfully remove a domain account from a local machine

The only problem with this is that I need to somehow enumerate through the names and only try and remove it if it matches a list? And maybe make it so that it is not case sensitive.





removeUser("domain", "group")



public static void removeUser(string domainValue, string adGroupAccount)
{
try
{
string path = string.Format("WinNT://{0},computer", Environment.MachineName);
using (DirectoryEntry dirEntry = new DirectoryEntry(path))
{
DirectoryEntry groupEntry = new DirectoryEntry("WinNT://" + System.Environment.MachineName + "/Administrators,group");

try
{
groupEntry.Invoke("Remove", "WinNT://" + domainValue + @"/" + adGroupAccount + ",user");
groupEntry.CommitChanges();
MessageBox.Show("Account Removed Successfully");
groupEntry.Dispose();
}
catch (Exception cex)
{
MessageBox.Show(cex.Message + "\n" + cex.StackTrace + "\n" + cex.Source);
}

}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

}

}
GeneralRe: Question about adding/removing account Pin
GenJerDan24-Feb-11 3:33
GenJerDan24-Feb-11 3:33 
GeneralRe: Question about adding/removing account Pin
turbosupramk324-Feb-11 5:27
turbosupramk324-Feb-11 5:27 
AnswerRe: Question about adding/removing account Pin
SledgeHammer0123-Feb-11 10:29
SledgeHammer0123-Feb-11 10:29 
GeneralRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 11:07
turbosupramk323-Feb-11 11:07 
AnswerRe: Question about adding/removing account Pin
turbosupramk323-Feb-11 12:12
turbosupramk323-Feb-11 12:12 
Questiontimespan Pin
arkiboys23-Feb-11 5:18
arkiboys23-Feb-11 5:18 
AnswerRe: timespan Pin
OriginalGriff23-Feb-11 5:22
mveOriginalGriff23-Feb-11 5:22 
GeneralRe: timespan PinPopular
arkiboys23-Feb-11 5:52
arkiboys23-Feb-11 5:52 
GeneralRe: timespan Pin
OriginalGriff23-Feb-11 8:47
mveOriginalGriff23-Feb-11 8:47 
GeneralRe: timespan Pin
Pete O'Hanlon23-Feb-11 10:08
mvePete O'Hanlon23-Feb-11 10:08 
AnswerRe: timespan Pin
Luc Pattyn23-Feb-11 6:06
sitebuilderLuc Pattyn23-Feb-11 6:06 
JokeRe: timespan Pin
musefan23-Feb-11 6:16
musefan23-Feb-11 6:16 
GeneralRe: timespan Pin
Keith Barrow23-Feb-11 9:03
professionalKeith Barrow23-Feb-11 9:03 
GeneralRe: timespan Pin
musefan23-Feb-11 9:20
musefan23-Feb-11 9:20 
Questionbest way to inform the user about newly released application.? Pin
vinu.111123-Feb-11 1:09
vinu.111123-Feb-11 1:09 
AnswerRe: best way to inform the user about newly released application.? Pin
Richard MacCutchan23-Feb-11 2:12
mveRichard MacCutchan23-Feb-11 2:12 
AnswerRe: best way to inform the user about newly released application.? Pin
OriginalGriff23-Feb-11 2:22
mveOriginalGriff23-Feb-11 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.