Solved

C# code for adding a computer to Active Directory

Posted on 2008-10-22
5
1,658 Views
Last Modified: 2013-12-17
HI

I need help with adding a computer to Active Directory using c#

Given parameters:

1) Computer name
2) LDAP path in which the computer is created
3) The user that is associated with this computer
4) The password of the user that is associated with this computer

0
Comment
Question by:elimesika
  • 2
  • 2
5 Comments
 
LVL 8

Assisted Solution

by:mikainz
mikainz earned 50 total points
ID: 22774867
0
 
LVL 15

Assisted Solution

by:angus_young_acdc
angus_young_acdc earned 450 total points
ID: 22774869
0
 
LVL 19

Author Comment

by:elimesika
ID: 22775478
HI mikainz & angus_young_acdc

Sorry, non of those links talks about adding computers, I have already managed the code for adding users.

I would appreciate a more specific , with relevant sample code answer.

Thanks
0
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 450 total points
ID: 22775803
I would imagine its a very similar process to adding a user.  Selecting the group (the workstations), and adding the name, location and other properties.  Something similar to the following:
            DirectoryEntry dirEntry = new DirectoryEntry("LDAP://");
            dirEntry.Properties["CompName"].Add("myCompName");
            dirEntry.Properties["UserName"].Add("myUserName");
            dirEntry.Properties["Password"].Add("myUsersPassword");
            dirEntry.CommitChanges();
            dirEntry.Close();
0
 
LVL 19

Author Closing Comment

by:elimesika
ID: 31508675
thanks for your time.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
consuming an asmx web service in winforms application 3 24
active directory 5 47
Javascript and Jquery not firing 9 39
How to add <appSettings> to the webconfig file 2 20
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now