????? ????? ?????? ??? ?????? ?????? ???????? ????? ?????? ? Visual C#

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

?? ??? ??????

??????

???? ??? ??????? ???? ????? ????? ??????? ????? ????? DirectoryServices ?????? ?????? ??? ?????? "?" ?????? ??????.

???????

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

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

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

    ?????? ?? Microsoft Visual C# 2005 ?? ?? Microsoft Visual 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 ?????? ?? ?? ?????? ???? ?? ?????? ????? ??? ???????? Guest:

    1. ?? ??????? ???? ? ???? ??? ??????? ???? ??? ????? ?????? ?? ?? ???? ??? ????? ?????????.
    2. ???? ??? ????? ???? ????????? ??????????? ????????. ??? ?? ???? ???? ???? ??? ???? ?????????? ???????? ??? ???? ?????? ?????.
    ???? ??????? ??????? ??? ???? ??????? ????? ??? ???? ??????? Windows XP ?????? ?? ?? ?????? ???? ?? ?????? ????? ??? ???????? Guest:
    1. ?? ??????? "????" ? ???? ??? "???? ??????".
    2. ???? ????? ??????? ??? ??????. ??? ?? ???? ???? ?????? ???? ?? ???? ?????? ?????? ??????????.
    ?????? ???: ????? ???? ?????? ?? ?????? ?????? ?? ?????? ??? ???????? ?? ??????.

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

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

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

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

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

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

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

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

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

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

??? ????????? ???????? ?? ??? ??????? ??? ????? ????? ??????? ?????? ???? ???????? ????? ?????? ???? ??????. ??? ?? ???? ????? ?????? ????????? ?? ???? ???????? ??????? ???? ???? ???????? ?????? ?????? ???????? ????? ????????? ?????? ?????? ?????? ???? ?????? ?????.

???????

???? ???????: 306273 - ????? ??? ??????: 20/?? ??????/1427 - ??????: 2.4
????? ???
  • Microsoft Visual C# 2008 Express Edition
  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbmt kbhowtomaster KB306273 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????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