Click here to Skip to main content
13,147,956 members (77,083 online)
Click here to Skip to main content

Stats

193.1K views
7.1K downloads
83 bookmarked
Posted 21 Jul 2009

Using System.DirectoryServices.AccountManagement

, 21 Jul 2009
In this article, we will be focusing on creating, editing, and deleting both user accounts or groups on the Active Directory or Machine SAM by using the System.DirectoryServices.AccountManagement namespace that .NET Framework 3.5 includes.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.DirectoryServices.AccountManagement;

namespace AccountManagementGUI
{
    public partial class frmProperties : Form
    {
        public frmProperties(object propertyItem, frmMain.ActionTypes actionType)
        {
            InitializeComponent();
            if (propertyItem is List<Principal>)
            {
                pgMain.SelectedObject = ((List<Principal>)propertyItem).ToArray();
            }
            else
            {
                pgMain.SelectedObject = propertyItem;
            }
            btnAction.Text = actionType.ToString();
            btnAction.Visible = (actionType != frmMain.ActionTypes.None);

        }

        private void btnAction_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Tamer Oz
Team Leader
Turkey Turkey
Tamer Oz is a Microsoft MVP and works as Assistant Unit Manager.

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 21 Jul 2009
Article Copyright 2009 by Tamer Oz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid