???? ?????????? ?? ??????? ?????? ?????????? ?????? ?? ????? C# ?? ????? ?? ?????? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 306273 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ???? ????? ?? ????? ???? ????DirectoryServices??????? ?????? ?? ?? ???? ?? ??? ???? ?????????? ?? ????? ?? ??? ??? ????? ???

??????????

  • Microsoft Windows XP, Windows 2000 ?? Windows NT 4.0
  • ????? C#

????? ?????

  1. Microsoft Visual Studio .NET 2003, Microsoft Visual Studio 2005 ?? Microsoft Visual Studio 2008 ?? ??????? ????, ?? ???? ??? ????? C# ????? ????????? ??? ??? ????????? ??????
  2. ?????? Explorer ???, ???? ????????????? ????-????? ????, ?? ???? ????????? ??????.
  3. ???? ?????? ??????System.DirectoryServices.dll????????
  4. Class1.cs ????? ??? ??? ?? ????? ??? ?? ???????????? ?????

    ???:Microsoft Visual C# 2005 ?? Visual Microsoft C# 2008, ??? Class1.cs ????? Program.cs ????? ?? ???????????? ???? ???
    using System;
    using System.DirectoryServices;
    
    class Class1
    {
        static void Main(string[] args)
        {
        try
            {
    	 DirectoryEntry AD = new DirectoryEntry("WinNT://" + 
    	                     Environment.MachineName + ",computer");
    	 DirectoryEntry NewUser = AD.Children.Add("TestUser1", "user");
    	 NewUser.Invoke("SetPassword", new object[] {"#12345Abc"});
    	 NewUser.Invoke("Put", new object[] {"Description", "Test User from .NET"});
    	 NewUser.CommitChanges();
    	 DirectoryEntry grp;
    
    	 grp = AD.Children.Find("Guests", "group");
    	 if (grp != null) {grp.Invoke("Add", new object[] {NewUser.Path.ToString()});}
    	 Console.WriteLine("Account Created Successfully");
    	 Console.ReadLine();
    	}
        catch (Exception ex)
    	{
    	 Console.WriteLine(ex.Message);
    	 Console.ReadLine();
    
    	}
        }
    }
    					
  5. ?????? ????, ?? ??? ????????? ?? ??????
  6. ???????? ???? ?? ???? ????? ??? ?? ?? ????? ???? ??? ????? ???? ?? ??? Windows 2000-?????? ???????? ?? ????? ????? ?? ???? ????:

    1. ????????????? ??,????????????? ????? ????,???????????? ??????? ????-????? ????, ?? ???? ??????????? ???????.
    2. ??????? ???? ?? ??? ????? ??????????? ?????????? ?? ??????? ??? ?? ???? ?? ??????? ????? ???? ?????Users???, ??? ?? ???? ?? ??? ??? ?? ?????????????????
    ???????? ???? ?? ???? ????? ??? ?? ?? ????? ???? ??? ????? ???? ?? ??? Windows XP-?????? ???????? ?? ????? ????? ?? ???? ????:
    1. ????????????? ??,???????? ????.
    2. ???-????? ?????????????? ????. ??? ?????????? ???? ??? ????? ???? ??????????????? ????????? ????? ?? ??????? ?? ??? ?? ..
    ?????????? ???: ?? ???? ?? ?????????? ???? ?? ?????? ?? ????? ???? ?????? ???? ?? ????

??? ?? ??????????

??? ?? ?????????? ????????? ?????

?? ????? ??? ?????????? ????????? ?????, ?? ?? ?? ?????? ?? ??? ?? Microsoft Windows NT, Windows 2000 ?? Windows XP ??? assumed ??? ????? ??? ?? ???????? ?? ??? ???? ??? ??DirectoryEntryconstructor ?? ???? ???? ?? "WinNT: / /"? ?? ???? ?????-???? ???????? ???????? ?? ?? ?????????? ???? ??? ???? ????
DirectoryEntry AD = new DirectoryEntry("WinNT://" + SystemInformation.ComputerName + ",computer");
				

?????????? ???? ?? ??? ?????????? ????????? ??????

????? ??? ?????? ?? ??DirectoryEntry?? ?????? ??????????????? ?? ???TestUser1???? ?? ????????? ???????????????
DirectoryEntry NewUser = AD.Children.Add("TestUser1", "user");
				

??????? ?? ??? ?????????? ???? ?? ??? ????? ??? ????

????? ??? ?????????? ??????????? ???? ?? ??? ????SetPassword, ???????? ??? ???????DirectoryEntry???????? ??? ?? ??????? ??? ???? ?? ?? ?????????? ???? ?? ??? ??? ????? ???? ??? ?? ??? ?? ???CommitChanges?????????? ?? ?????? ?? ??? ?????? ???
NewUser.Invoke("SetPassword", new object[] {"#12345Abc"});
NewUser.Invoke("Put", new object[] {"Description", "Test User from .NET"});
NewUser.CommitChanges();
				

?? ???? ?? ??? ???? ??????

????? ?? ??? ???? ???? ?? ???, ????? ????? ?? ???? ????:
  1. ?? ?????? ?? ??? ?? ????????? ????DirectoryEntry.
  2. ??????????? ??? ???????????? ?????ActiveDirectory???? ?? ????????? ???? ?? ??? ??? ?? ?????? ???, ????? ???? ??? ?? ?????? ??? ?? ??? tests ??? ??????????? ???? ???? ??? ?? ?? ???????? ???? ?? ??? ???? ???? ??? ??? ???? ????? ??, ?? ??? ?????????? ???? ???? ??? ????? ??? ???
DirectoryEntry grp;
grp = AD.Children.Find("Guests", "group");
if (grp != null) {grp.Invoke("Add", new object[] {NewUser.Path.ToString()});}
				

?????? ??????

?? ???? ??? ??? ???? ?? ???? ?? ??? ?? ???? ???? ?????????? ???? ????? ?? ??? ???????? ??????????? ??? ?? ????? ?? ??? ?????? ????? ??????????? ????? ???? ?? ??? ??? ?? ??? ??????? ??? ??? ?? ?????????? ?????? ???????????? ?? ???? ?? ????? ???? ?? ?????????? ???? ????? ?? ??? ?????????? ?? ?????? ??? ????? ????????? ????

???

???? ID: 306273 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual C# 2008 Express Edition
  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET 2002 Standard Edition
??????: 
kbhowtomaster kbmt KB306273 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:306273

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com