Need help with joining domain

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Steele

    #1

    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
    NetRenameMachin einDomain. This is basically what I'm doing:

    NetJoinDomain(" ", domain, "OU=Notebooks,D C=ad,DC=acadiau ,DC=ca", username,
    password, NETSETUP_JOIN_D OMAIN | NETSETUP_ACCT_C REATE |
    NETSETUP_DEFER_ SPN_SET);

    NetRenameMachin eInDomain("", computerName, username, password,
    NETSETUP_ACCT_C REATE);

    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
    NetRenameMachin eInDomain, the rename works properly. However, there is no
    indication that a reboot is required after calling NetJoinDomain before
    using
    NetRenameMachin eInDomain. 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.



  • Eric Cadwell

    #2
    Re: Need help with joining domain

    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


    Comment

    Working...