473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help with joining domain

I am writing a C# program to automate the deployment of new notebooks the
first time they are booted after sysprep has done it's thing. I want to join
the notebook to our domain and give it a specific name based on user input.
The two functions I am using for this purpose are NetJoinDomain and
NetRenameMachineinDomain. This is basically what I'm doing:

NetJoinDomain("", domain, "OU=Notebooks,DC=ad,DC=acadiau,DC=ca", username,
password, NETSETUP_JOIN_DOMAIN | NETSETUP_ACCT_CREATE |
NETSETUP_DEFER_SPN_SET);

NetRenameMachineInDomain("", computerName, username, password,
NETSETUP_ACCT_CREATE);

The call to the first function works properly. The call creates a computer
account in the OU indicated and joins the computer to the specified domain.
The call to the rename function almost works as well. The domain account is
renamed with the new computer name, but the function returns error code 2221
and does not rename the local computer name to match the new domain name.
Error code 2221 is define as "The username could not be found". There is no
indication what the username it's complaining about, but I can only assume
that it's the domain username and password.

If I reboot the computer between calls to NetJoinDomain and
NetRenameMachineInDomain, the rename works properly. However, there is no
indication that a reboot is required after calling NetJoinDomain before
using
NetRenameMachineInDomain. I want to avoid excessive reboots to make the
process go more quickly for the user.

If anyone has used these functions in a similar situation and has any
suggestions, I'd appreciate hearing from you. Thanks.

Jul 21 '05 #1
1 2373
I haven't used these functions, but I have tried to manually do what you are
attempting and failed.
I believe you should be renaming the local machine first, then joining it to
the domain.

-Eric
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
0
by: Paul Steele | last post by:
This isn't really a question on .NET, although it is network related. There doesn't seem to be a way in .NET to work with domains in any case. I am writing a C# program to automate the...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
1
by: Paul Steele | last post by:
I am writing a C# program to automate the deployment of new notebooks the first time they are booted after sysprep has done it's thing. I want to join the notebook to our domain and give it a...
6
by: joseph speigle | last post by:
hi, Does anybody know offhand what is the correct way to use substr to extract the domain name from a client_referer column as logged by mod_pgsqllog (httpd module), by correcting the following: ...
2
by: jeremiah johnson | last post by:
I have a .net DLL that I've created (based on someone's post in this group, sorry I've forgotten who) and I need a little help with making it work. I want to provide the same functionality as...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
2
by: Supermansteel | last post by:
I am joining these 2 tables together in Access 2003 and can't figure out the exact way of writing this script......Can anyone help? I have the following SQL: SELECT...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.