I am needing a little help on how to add a newly created user to a few domain groups after the initial creation.
Here is the code I have thus far.
As you can see I create the user by using inputbox promtpts then set the users terminal server settings we need. The problem is I also need to add the user to 3 - 5 global security goups in AD as well.
any help would be geatly appreciated!!
I have googled many examples, but nothing seems to fit or I am not seeing how they could be used.
Thanks!!!!!!
Thanks
John Fuhrman
Titan Global Services
Here is the code I have thus far.
Code:
'*******************************************************************
' Author: John Fuhrman
' Lenexa Outlink Data Center
' 10910 W. 87th
' Lenexa, Ks 66215
'
' Date: 12/18/2006
' Revision: 3.3
'
' Script to create bank Terminal Server user
' accounts for the Outlink Data Center.
'*******************************************************************
strOU= InputBox("Enter the Organizational Unit of the User" &_
vbCrLf & "to be created.")
If strOU = False Then Call NO_OU(1)
If strOU = "" Then Call NO_OU(2)
' If IsNumeric(strOU) = False Then Call NO_OU(3)
strName = InputBox("Enter the Logon ID of the User" &_
vbCrLf & "to be created.")
If strName = False Then Call NOName(1)
If strName = "" Then Call NOName(2)
' If IsNumeric((Left(strName,3))) = False Then Call NOName(3)
strFirstName = InputBox("Enter the User's First Name")
If strFirstName = False Then Call NOName(1)
If strFirstName = "" Then Call NOName(2)
strLastName = InputBox("Enter the User's Last Name")
If strLastName = False Then Call NOName(1)
If strLastName = "" Then Call NOName(2)
strBrowserUser = MsgBox("Is this a BROWSER user?",vbYesNo)
If strBrowserUser = vbNo Then strBrowser = "corelogin.bat"
If strBrowserUser = vbYes Then strBrowser = "corebrow.bat"
strTellerUser = MsgBox("Is this a Teller user?",vbYesNo)
If strTellerUser = vbYes Then strTeller = Disabled
If strTellerUser = vbNo Then strTeller = Enabled
Call Password()
Call Main()
Call Quit(2)
Sub Main()
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
Set objRoot = GetObject("LDAP://rootDSE")
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objDomain = GetObject("LDAP://" &_
objRoot.Get("defaultNamingContext"))
Set objOU = GetObject("LDAP://OU=" &_
strOU & "," & strDNSDomain)
'Create the new User
On Error Resume Next
Set objUser = objOU.Create("User", "cn=" & strFirstName & " " & strLastName)
objUser.Put "sAMAccountName", strName
objUser.Put "givenName", strFirstName
objUser.Put "sn", strLastName
objUser.Put "distinguishedName", strFirstName & " " & strLastName
objUser.Put "displayName", strLastName & "," & strFirstName
objUser.Put "userPrincipalName", strName & "@corebanks.jackhenry.com"
objUser.SetInfo
If Err.number <> 0 Then Call Quit(1)
'Set User TS environment
Set objUser = objOU.GetObject ("User", "cn=" & strFirstName & " " & strLastName)
Const Enabled = 1
Const Disabled = 0
If objUser.class = "user" Then
objUser.ConnectClientDrivesAtLogon = Disabled
objUser.ConnectClientPrintersAtLogon = strTeller
objUser.DefaultToMainPrinter = strTeller
objUser.TerminalServicesInitialProgram = _
"\\%machine%\users\%username%\bk" &_
strBank & "\" & strBrowser
objUser.TerminalServicesWorkDirectory = ""
' objUser.TerminalServicesProfilePath = _
' "\\corebanks\folders\Profiles\" & objUser.SamAccountName
objUser.TerminalServicesHomeDirectory = ""
objUser.TerminalServicesHomeDrive = ""
objUser.AllowLogon = Enabled
objUser.IsAccountLocked = True
objUser.SetPassword strInputReturn1
objUser.Put "pwdLastSet", Disabled
objUser.AccountDisabled = false
objUser.SetInfo
End if
'objUser.SetPassword StrPassword1
'objUser.SetPassword StrPassword2
'objUser.Put "pwdLastSet", Enabled
End Sub
Function Password()
strPassword = InputBox("Enter the User's Password")
If strPassword = False Then Call NOPassword(1)
If strPassword = "" Then Call NOPassword(2)
strConfPassword = InputBox("Enter the User's Password")
If strConfPassword = False Then Call NOPassword(1)
If strConfPassword = "" Then Call NOPassword(2)
If strPassword <> strConfPassword Then
Call PasswordMisMatch(1)
Else strInputReturn1 = strPassword
End If
End Function
Function BrowserUser()
strBrowserUser = InputBox("Is this a BROWSER user?")
If strBrowserUser = False Then strBrowser = "corelogin.bat"
If strBrowserUser = True Then strBrowser = "corebrow.bat"
End Function
Sub NO_OU(Error)
If Error = "1" Then MsgBox("Canceled")
If Error = "2" Then MsgBox("User's Organizational Unit not entered.")
If Error = "3" Then MsgBox("Invalid Organizational Unit Entered!" &_
vbCrLf & "Example: 001")
Call Quit(1)
End sub
Sub NOName(Error)
If Error = "1" Then MsgBox("Canceled")
If Error = "2" Then MsgBox("User's Name not entered.")
If Error = "3" Then MsgBox("Invalid User Name" & vbCrLf &_
"Example: 888$jsmith")
Call Quit(1)
End sub
Sub NOPassword(Error)
If Error = "1" Then MsgBox("Canceled")
If Error = "2" Then MsgBox("User's Password not entered.")
Call Quit(1)
End Sub
Sub PasswordMisMatch(Error)
If Error = "1" Then MsgBox("Passwords Do NOT Match" &_
vbCrLf & "Try Again.")
Call Password()
End Sub
Sub Quit(Error1)
If Error1 = "1" Then MsgBox("Script Canceled!!")
If Error1 = "2" Then MsgBox("User Account Created.")
WScript.Quit
End Sub
Sub Sure(Error1)
If Error = "1" Then strYN = MsgBox("Are you sure?", 4, "Enter OU Prompt")
If strYN = 6 Then
If strYN = 7 Then Call Quit(1)
End If
End Sub
As you can see I create the user by using inputbox promtpts then set the users terminal server settings we need. The problem is I also need to add the user to 3 - 5 global security goups in AD as well.
any help would be geatly appreciated!!
I have googled many examples, but nothing seems to fit or I am not seeing how they could be used.
Thanks!!!!!!
Thanks
John Fuhrman
Titan Global Services