0
votes

I am trying to add a domain user account to a local group and everything works fine if I am logged into the computer but if I run the same script under the SYSTEM account it fails with the error: 424 Object Required". Here is the code:

Dim domain          : domain           = "DOMAIN01"
Dim domainController: domainController = "99.139.151.102"
Dim localComputer   : localComputer    = "SERVER001"
Dim localGroup      : localGroup       = "LocalGroup1"
Dim domainAccount   : domainAccount    = "User1"
Dim objLocalGroup
Dim objDomainUser

Set objLocalGroup = GetObject("WinNT://" & localComputer    & "/" & localGroup    & ",group")
Set objDomainUser = GetObject("WinNT:").OpenDSObject("WinNT://" & domain & "/" & domainController & "/" & domainAccount, domainAccount, "Password1234", ADS_SECURE_AUTHENTICATION or ADS_SERVER_BIND)

  'Add domain user to local group.
  objLocalGroup.Add(objDomainUser.ADsPath)

  If Err.Number <> 0 Then
       WScript.Echo Err.Number
       WScript.Echo Err.Description
  Else
       WScript.Echo domainAccount & " has been added to local group " & localGroup
  End If

Thank you

1

1 Answers

0
votes

The SYSTEM account has no business connecting to other hosts. Run the script as a user with local admin privileges.