R
rx7keg
Guest
Hey guys, long time user viewer of sythe - i have a question on some for the VB Gods in here 
i have a Vbs script witch i have tried to add into a VB6 application
here is a screen shot i have made of the GUI
Now im wondering if some one could create and application with the script i have posted - as i have tried but i dont know were i am going wrong - this script works well useing adduser.vbs but as soon as i add it into my application interface it fails
if some one could help that would be grate
Thanks
RX7
i have a Vbs script witch i have tried to add into a VB6 application
here is a screen shot i have made of the GUI
Code:
Option Explicit
'Input Strings
Dim strfirstname,strlastname,strdivision,strfunction,stremailaddress,strOffice,strHomeDirectory,strUsername,oWshShell
'Objects
Dim objRootDSE,objContainer,objUser,oFSO
'Variables
dim strSubOU,Count,varAnother
Dim intRdm
'Set the Base OU
CONST strBaseOU = "ou=nz"
'Set Constants
CONST strHomeDrive = "H:"
CONST strFileServer = "NZWELLMEYFP01"
CONST varPasswordSize = "8"
CONST strPrincipalNameSuffix = "@tcnz.co.nz"
CONST WINDOW_STYLE = 2 'Controls how external applications that are called will be displayed
CONST strDomainCOntroller = "nzwellmeyad01" 'Sets the domain controller to add user to (This should be the dc in the same site as the fileserver
CONST strPassword = "passw0rd!"
Set oWshShell = Wscript.CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
varAnother = "y"
Do While Lcase(varAnother) = "y"
'***********************************************
'* Prompt for user information *
'***********************************************
strfirstname = InputBox("Enter users first name")
strlastname = InputBox("Enter users last name")
strdivision = InputBox("Enter Users Division" & vbCRLF & vbCRLF & "SS/ES/CS/CF/FR/XX")
strfunction = InputBox("Enter Users Function eg Audit,ASG etc" & vbCRLF & vbCRLF & "Refer to AD Users and Computers Managment GUI for list)")
stremailaddress = Inputbox("Enter Users email address")
Dim VarOffice
VarOffice = 0
Do while VarOffice < 1 or VaroFFICE > 3
varOffice = InputBox("Enter Users Office location" & vbCRLF & vbCRLF & "1) Auckland" & vbCRLF & "2) Wellington" & vbCRLF & "3) Christchurch")
Select Case varOffice
Case 1
strOffice = "Auckland"
Case 2
strOffice = "Wellington"
Case 3
strOffice = "Christchurch"
case Else
MsgBox ("Invalid Option. TryAgain")
End Select
Loop
If strFunction = Null then
strSubOU = "ou=" & strDivision
Else
strSubOU = "ou=" & strFunction & ",ou=" & strDivision
End If
'***********************************************
'* Connect to a container *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strSubOU = " " Then
Set objContainer = GetObject("LDAP://" & strDomainCOntroller & "/" & strBaseOU & "," & objRootDSE.Get("defaultNamingContext"))
Else
Set objContainer = GetObject("LDAP://" & strDomainCOntroller & "/" & strSubOU & "," & strBaseOU & "," & objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to a container *
'***********************************************
'Construct Home Directory UNC Path
strHomeDirectory = "\\" & strFileServer & "\" & strFirstName & "." & strLastName & "$"
'Construct Username
strUsername = strFirstName & "." & strLastName
'***********************************************
'* Create User *
'***********************************************
Set objUser = objContainer.Create("user", "cn=" & strFirstName & " " & strLastName)
objUser.Put "sAMAccountName", strUsername
objuser.Put "Displayname", strFirstName & " " & strLastName
objuser.Put "givenname", strFirstName
objuser.Put "sn", strLastName
objuser.Put "userprincipalname", strUsername & strPrincipalNameSuffix
objuser.Put "Homedirectory",strHomeDirectory
objuser.Put "Homedrive",strHomeDrive
objuser.Put "pwdLastSet", 0
objUser.Put "physicalDeliveryOfficeName", strOffice
objUser.Put "Mail", stremailaddress
objUser.SetInfo
objUser.SetPassword strPassword
objuser.SetInfo
'Create share
oFSO.CreateFolder("\\" & strFileServer & "\d$\tcHome\" & strFirstName & "." & strLastName)
owshShell.Run "c:\windows\rmtshare.exe " & strHomeDirectory & "=d:\eyhome\" & strFirstName & "." & strLastName & " /GRANT ANZ\" & strFirstName & "." & strLastName & ":C",WINDOW_STYLE,True
MsgBox ("User (" & strFirstName & "." & strLastName & ") created. Password is: " & strPassword)
varAnother = InputBox ("Add another user? Y/N")
Loop
Now im wondering if some one could create and application with the script i have posted - as i have tried but i dont know were i am going wrong - this script works well useing adduser.vbs but as soon as i add it into my application interface it fails
if some one could help that would be grate
Thanks
RX7



