Hi,
I'm a newbie so please forgive me.
I have the following code that I wrote for creating a new computer account in AD in a specified OU. It works great BUT now I need to change the account so that the security allows a specific group to use the newly created computer account to join the domain. The equivalent of changing the "User or Group" field on the first page of the create new computer form in AD users and computer. My issue is I have no idea how to do that (big issue). Any pointers?Public Sub CreateADAccount()
Dim strComputer, strOU, strDesc As String
Dim objRootLDAP, objContainer, objLeaf
strComputer = ComputerName.Text
strOU =
"ou=Workstations,ou=" & Users_Office.Text & ",ou=" & Users_Geography.Text & ",ou=United States,ou=Americas,dc=corp,dc=pbwan,dc=net ," ' Note the comma
' Bind to Active Directory, Computers container.
objRootLDAP = GetObject(
"LDAP://rootDSE")
If Users_Office.Text = "Guam" Then
objContainer = GetObject(
"LDAP://ou=Workstations,ou=Guam,ou=Americas,dc=corp,dc=pbwan,dc=net")
Else
"LDAP://ou=Workstations,ou=" & Users_Office.Text & ",ou=" & Users_Geography.Text & ",ou=United States,ou=Americas,dc=corp,dc=pbwan,dc=net"
End If
If MakeDell.Checked = True Then
strDesc = Users_Name.Text &
"," & DellModel.Text & "," & TagNo.Text & "," & ExpressCode.Text & "," & PONumber.Text & "," & LanAdmin_Name.Text & "," & RegistrationDate.Text
ElseIf MakeHP.Checked = True Then
"," & HPModel.Text & "," & TagNo.Text & "," & PONumber.Text & "," & LanAdmin_Name.Text & "," & RegistrationDate.Text
end If
' Build the actual computer.
objLeaf = objContainer.Create(
"Computer", "cn=" & strComputer)
objLeaf.Put(
"sAMAccountName", strComputer & "$")
"userAccountControl", 4096)
"Description", "Details - " & strDesc)
objLeaf.SetInfo()
Sleep(3000)end Sub
(Sorry this text editor window messed up the formatting)
any help greatly received