Creating a user account in Active Directory using a specific domain controller

Discussion in 'Scripting' started by Morten Hansson, Oct 21, 2003.

  1. How do I create a user account in AD using a specific
    domain controller?
    I know how to create a user whitout knowing on whitch
    domain controller it is created.
    After i create the account, i do some tasks involving a
    specific domain controller. But if the AD has'nt been
    syncronized i run in to trouble!
    So i need to know on whitch domain controller the account
    is created, so that i can do the remaining tasks on the
    same domain controller.

    Many thanks

    Morten Hansson, Oct 21, 2003
    1. Advertisements

  2. Hi

    I think using OpenDSObject is a solution:

    When using VBScript, remember to define all necessary Const:


    Here is a VBScript example:


    sUser = "domain\userid"
    sPassword = "something"

    Set objIADsOpenDSObject = GetObject("LDAP:")
    On Error Resume Next
    Set pObjIADs = objIADsOpenDSObject.OpenDSObject( _
    "LDAP://server1/CN=Dept1,DC=Fabrikam,DC=com", _

    If Err.Number <> 0 Then
    MsgBox "OpenDSObject call failed with error " _
    & Err.description & " : " & Err.Number
    MsgBox "Connected"
    End If
    On Error Goto 0
    Torgeir Bakken (MVP), Oct 21, 2003
    1. Advertisements

  3. Thanks!
    It works perfectly.
    I was just missing the server/CN
    in "LDAP://server1/CN=Dept1"

    - Morten
    Morten Hansson, Oct 23, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.