using System.DirectoryServices;
using System.Runtime.InteropServices;
using System;
class ADuser
{
public static void Main()
{
try
{
string strNodeName = "TestUser";
DirectoryEntry NewUser;
//Bind and get the computer container
DirectoryEntry AD = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");
// delete user when existing
try
{
// this throws when no such user
NewUser = AD.Children.Find(strNodeName, "User");
AD.Children.Remove(NewUser);
}
// Catch not found exception
catch(COMException cex)
{
Console.WriteLine(cex.Message);
}
using System.Runtime.InteropServices;
using System;
class ADuser
{
public static void Main()
{
try
{
string strNodeName = "TestUser";
DirectoryEntry NewUser;
//Bind and get the computer container
DirectoryEntry AD = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");
// delete user when existing
try
{
// this throws when no such user
NewUser = AD.Children.Find(strNodeName, "User");
AD.Children.Remove(NewUser);
}
// Catch not found exception
catch(COMException cex)
{
Console.WriteLine(cex.Message);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货