Click here to Skip to main content
15,916,042 members
Home / Discussions / C#
   

C#

 
Questionc# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 15:13
lanpartyes23-Feb-11 15:13 
AnswerRe: c# Need help getting WPF window to draw behind desktop icons Pin
SledgeHammer0123-Feb-11 18:13
SledgeHammer0123-Feb-11 18:13 
GeneralRe: c# Need help getting WPF window to draw behind desktop icons Pin
lanpartyes23-Feb-11 23:49
lanpartyes23-Feb-11 23:49 
Questionvb.net to c#.net Pin
David C# Hobbyist.23-Feb-11 14:49
professionalDavid C# Hobbyist.23-Feb-11 14:49 
AnswerRe: vb.net to c#.net Pin
RobCroll23-Feb-11 16:18
RobCroll23-Feb-11 16:18 
AnswerRe: vb.net to c#.net Pin
thatraja23-Feb-11 16:29
professionalthatraja23-Feb-11 16:29 
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 
The code below works perfect with
removeUser("testuser")
but will not work with
removeUser("domain\test user name")

Does anyone have any idea as to why?



using System;
using System.IO;
using System.Text;
using Microsoft.Win32;
using System.Security;
using System.Threading;
using System.Reflection;
using System.Diagnostics;
using System.Configuration;
using System.Globalization;
using System.ComponentModel;
using System.DirectoryServices;
using System.Security.Principal;
using System.Collections.Generic;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;
using System.Windows.Forms;

namespace AD
{
    class ActiveDirectory
    {

     public static void removeUser(string userName)
        {
            try
            {
                string path = string.Format("WinNT://{0},computer", Environment.MachineName);
                using (DirectoryEntry dirEntry = new DirectoryEntry(path))
                {
                    DirectoryEntry groupEntry = dirEntry.Children.Find("Administrators", "group");
                    if (groupEntry != null)
                    {

                        DirectoryEntry userEntry = dirEntry.Children.Find(userName, "user");
                        groupEntry.Invoke("Remove", new object[] { userEntry.Path.ToString() }); 
                        groupEntry.CommitChanges();
                        userEntry.Dispose();
                    }
                    groupEntry.Dispose();

                    MessageBox.Show("Account Removed Successfully");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }

        }
    }
}

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 
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 PinPopular
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 PinPopular
Luc Pattyn23-Feb-11 6:06
sitebuilderLuc Pattyn23-Feb-11 6:06 

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.