Hello All, I am very new to VBScript so your help is greatly appreciated. I
have been given the task of insourcing Exchange Mailbox creation and want
to integrate the mailbox creation into our createuser vbscript. Here is
the script I am using but the mailboxes are not getting created. Using
Primal Script debug no errors are returned. Help!!!
Sub CreateSOIUser
'*************************************************************
' Create a user in the SOI domain
'*************************************************************
'Local Variables
Dim ads, adsUsr, sID, sFName, sLName, sMI, sPswd, sDescription
Dim rs, sSQL, sSite, sOrg, adsGrp, sGrpPath
Dim adsUsrSuper, sSuper, sSuperPath, sEmpType, sTitle, sEmpID
Dim iAutoID
'Error handling
If bDebug = False Then
On Error Resume Next
End If
'OU Paths
'Const USR_OU =
"LDAP://stlsoidc2.SOI.DIR.SOLUTIA.COM/OU=USERS,OU=%SITE%,OU=%ORG%,DC=soi,DC=dir,DC=solutia,DC=com"
'Const NET_OU =
"LDAP://stlsoidc2.SOI.DIR.SOLUTIA.COM/OU=NETRESOURCES,OU=%SITE%,OU=%ORG%,DC=soi,DC=dir,DC=solutia,DC=com"
Const USR_OU =
"LDAP://AUBSOIDC1.SOI.DIR.SOLUTIA.COM/OU=USERS,OU=%SITE%,OU=%ORG%,DC=soi,DC=dir,DC=solutia,DC=com"
Const NET_OU =
"LDAP://AUBSOIDC1.SOI.DIR.SOLUTIA.COM/OU=NETRESOURCES,OU=%SITE%,OU=%ORG%,DC=soi,DC=dir,DC=solutia,DC=com"
'Create a recordset database object
Set rs = CreateObject("ADODB.Recordset")
'Open a recordset of the users that need to be created.
sSQL = "SELECT * FROM vwCreateSoiUsers ORDER BY Unique_Identifier"
rs.Open sSQL, conSam
UpdateStatus "Creating SOI Accounts"
'Loop through each user needing created.
Do While Not rs.EOF
Err.Clear
'Get information needed to create the account.
iAutoID = rs("AutoID")
sID = lcase(rs("Unique_Identifier"))
sFName = Proper(rs("FirstName"))
sLName = Proper(rs("LastName"))
sMI = Proper(rs("MI"))
sDescription = Proper(rs("mailZone"))
sSite = rs("fldSiteCode")
sOrg = rs("fldOrgCode")
If Not IsNull(rs("Supervisor_Name")) Then
sSuper = rs("Supervisor_Name")
Else
sSuper = rs("Requester")
End If
If Not IsNull(rs("Employee_Type")) Then
sEmpType = rs("Employee_Type")
Else
sEmpType = ""
End If
If Not IsNull(rs("EMPID")) Then
sEmpID = rs("EMPID")
Else
sEmpID = ""
End If
UpdateStatus String(1, vbTab) & "Attempting to create user " & sID
'Build the path to the ou to create the user in.
sPath = Replace(USR_OU, "%SITE%", sSite)
sPath = Replace(sPath, "%ORG%", sOrg)
UpdateStatus String(2, vbTab) & "Creating in the '" & sPath & "' OU"
'Build the full name to create the user
sName = Trim("cn=" & sLName & "\, " & sFName & " " & sMI)
'Bind to the parent ou to create the user in
Set ads = GetSOI(sPath)
'Create the user
Set adsUsr = ads.Create("User", sName)
'Assign account information to the new account
adsUsr.Put "sAMAccountName", sID
adsUsr.FirstName = sFName
adsUsr.LastName = sLName
Set objMailbox = objPerson.GetInterface("IMailboxStore")
objMailbox.CreateMailbox "LDAP://CN=" + _
SG3LGTMDB2 + _
",CN=" + _
SG3LGTMDB2 + _
",CN=" + _
SG3CL002 + ",CN=InformationStore,CN=" + _
USAHMSLSOIEX2 + _
",CN=Servers,CN=" + _
AdminGroup + "," + _
"CN=Administrative Groups,CN=" + _
ExchangeOrg + "," + _
"CN=Microsoft Exchange,CN=Services," + _
"CN=Configuration," + domainDN
objPerson.DataSource.Save
'Save the information
adsUsr.SetInfo
'Check to see if there were any errors while creating the user.
Select Case Err.Number
Case 0
'No error
' enable account
adsUsr.AccountDisabled = False
' set the description of the user
adsUsr.Description = sDescription
' save the information again.
adsUsr.SetInfo
'Wait 60 nano-seconds
WScript.Sleep 60
'Set the password of the user
adsUsr.SetPassword LCase(left(sID, 3)) & "Solutia99"
' set that the user must reset their password the
' next time they logon
adsUsr.put "pwdLastSet", 0
'Set the manager for non-solutia users
If sEmpType = "S" Or sEmpType = "" Then
If sEmpID <> "" Then
adsUsr.Put "EmployeeID", sEmpID
End If
Else
If sSuper <> "" Then
sSuperPath = Qry4Obj(sSuper, "User", False)
If sSuperPath <> "" Then
Set adsUsrSuper = GetObject(sSuperPath)
adsUsr.Put "Manager", adsUsrSuper.DistinguishedName
Set adsUsrSuper = Nothing
End If
Else
'nothing to do
End If
End If
'Save this change
adsUsr.Setinfo
UpdateStatus String(2, vbTab) & "Created " & adsUsr.Name
'Add the user to the 'Users' group of the site they are
at.
sGrpPath = Replace(NET_OU, "%SITE%", sSite)
sGrpPath = Replace(sGrpPath, "%ORG%", sOrg)
UpdateStatus String(3, vbTab) & "Working on group " &
sGrpPath
Set adsGrp = GetObject(sGrpPath)
adsGrp.Add adsUsr.adsPath
'Check to see if there were any errors while adding
' the user to the group
Select Case Err.Number
Case 0
'No error
UpdateStatus String(2, vbTab) & "Added " & adsUsr.Name
& " to the group " & adsGrp.Name
Case Else
'There was an error, update the operator of that error
UpdateStatus String(2, vbTab) & "Error: " & Err.Number
& ": " & Err.Description
UpdateStatus String(3, vbTab) & "While adding " &
adsUsr.Name & " to the group " & adsGrp.Name
End Select
Err.Clear
'Update SamTracking that the SOI account was created.
If rs("fldSam") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 3, "EMAIL", sPO, "L"
UpdateStatus String(3, vbTab) & "UpdateD Messaging
Team's Status in SamTracking."
Elseif rs("fldSOI") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 2, "SOI", sPO, "L"
UpdateStatus String(3, vbTab) & "UpdateD SOI Team's
Status in SamTracking."
'SAM_CreateSOIUser rs("AutoID")
Else
UpdateStatus String(3, vbTab) & "did not updatedate
Team's Status in SamTracking."
End If
Case 80071392
'User already exists
If rs("fldSam") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 3, "EMAIL", sPO, "L"
UpdateStatus String(3, vbTab) & "UPdated Messaging
Team's Status in SamTracking."
Elseif rs("fldSOI") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 2, "SOI", sPO, "L"
UpdateStatus String(3, vbTab) & "UPdated SOI Team's
Status in SamTracking."
'SAM_CreateSOIUser rs("AutoID")
Else
UpdateStatus String(3, vbTab) & "did not updatedate
Team's Status in SamTracking."
End If
'SAM_CreateSOIUser rs("AutoID")
UpdateStatus String(2, vbTab) & sID & " already exists!"
Err.Clear
Case -2147019886
'user already exists
'SAM_CreateSOIUser rs("AutoID")
UpdateStatus String(3, vbTab) & "'" & rs("fldSam") & "' "
& asc(rs("fldSam"))
If rs("fldSam") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 3, "EMAIL", sPO, "L"
UpdateStatus String(3, vbTab) & "UpDated Messaging
Team's Status in SamTracking."
Elseif rs("fldSOI") <> "0" Then
SAM_ChangeTeamStatus iAutoID, 2, "SOI", sPO, "L"
UpdateStatus String(3, vbTab) & "UpDated SOI Team's
Status in SamTracking."
'SAM_CreateSOIUser rs("AutoID")
Else
UpdateStatus String(3, vbTab) & "did not updatedate
Team's Status in SamTracking."
End If
UpdateStatus String(2, vbTab) & sID & " already exists!"
Err.Clear
Case Else
'There was an error while saving the initial information.
UpdateStatus String(2, vbTab) & "Error while creating
user " & sID & ": " & Err.Number & vbCrLf & Err.Description
End Select
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
UpdateStatus "Finished Creating SOI Accounts"
UpdateStatus ""
End Sub
Sub CompleteSOICreate
Glen Scales [MVP] - 21 Mar 2005 03:23 GMT
Try getting rid of the "On error Resume Next" and you should get some sort
of meaningful error message let us know what that is and someone here can
probably help out.
Cheers
Glen
> Hello All, I am very new to VBScript so your help is greatly appreciated.
> I
[quoted text clipped - 228 lines]
>
> Sub CompleteSOICreate
Scot Lymer - 29 Mar 2005 22:18 GMT
Here is the error I receive when I run this script.
Error: 438: Object doesn't support this property or method
Thanks to all who can help!!!
Glen Scales [MVP] - 30 Mar 2005 11:17 GMT
This means that one of the objects you are trying to use doesn't support a
method your trying to run or a property your trying to manipuate. To figure
which object it is you need to look at the line number the error happens on
(this is usually in the error message otherwise you may need to use echo
statements to find out how far the script is processing). The other thing to
be carefull of is that the machine you running the script on has the latest
Exchange service pack applied to it (eg if you are running it on a
workstation with Exchange System Manager installed make sure you install the
latest Exchange service pack on the machine to ensure you have the latest
copy of CDOEXM).
If you want to look at a working sample check out the scripts in
http://www.cdolive.com/download/ADUserManagement.zip
Cheers
Glen
> Here is the error I receive when I run this script.
>
> Error: 438: Object doesn't support this property or method
>
> Thanks to all who can help!!!
Scot Lymer - 30 Mar 2005 16:12 GMT
I run this script through PrimalScript's debugger and it show no errors.
Thanks for the help!!!