Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Add a Computer Domain

Add a Computer Domain

Scheduled Pinned Locked Moved C#
csharphelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chathura
    wrote on last edited by
    #1

    Do any know how to impliment adding a computer to domain using C#. I know you have to import System.Directory.Services.dll Can you please help thanks CJ:)

    M 1 Reply Last reply
    0
    • C Chathura

      Do any know how to impliment adding a computer to domain using C#. I know you have to import System.Directory.Services.dll Can you please help thanks CJ:)

      M Offline
      M Offline
      miahrugger
      wrote on last edited by
      #2

      Try something like the following:

      string domain = ...;
      string newComputer = ...;
      string groupName = ...;

      // Connect to AD and get the computer container object
      DirectoryEntry deDomain = new DirectoryEntry("WinNT://" + domain);
      DirectoryEntry deNewComputer = new DirectoryEntry("WinNT://" + domain + "/" + newComputer + ", computer");

      // Connect to the group container and add the computer object
      DirectoryEntry deGrp = deDomain.Children.Find(groupName, "Group");
      if (deGrp.Name != null)
      deGrp.Invoke("Add", new Object[]{deNewComputer.Path.ToString()});
      deGrp.CommitChanges();

      C 1 Reply Last reply
      0
      • M miahrugger

        Try something like the following:

        string domain = ...;
        string newComputer = ...;
        string groupName = ...;

        // Connect to AD and get the computer container object
        DirectoryEntry deDomain = new DirectoryEntry("WinNT://" + domain);
        DirectoryEntry deNewComputer = new DirectoryEntry("WinNT://" + domain + "/" + newComputer + ", computer");

        // Connect to the group container and add the computer object
        DirectoryEntry deGrp = deDomain.Children.Find(groupName, "Group");
        if (deGrp.Name != null)
        deGrp.Invoke("Add", new Object[]{deNewComputer.Path.ToString()});
        deGrp.CommitChanges();

        C Offline
        C Offline
        Chathura
        wrote on last edited by
        #3

        Thanks so much:-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups