I'm developing a script to create user accounts including a mailbox for each account.
The script creates the account and the mailbox correctly (using cdoexm) but I need it to be more specific/flexible about where the mailbox get created. Specifically, we have an Exchange server in each of our three offices, London, Hong Kong and New York, so a Hong Kong user should have their mailbox on the Hong Kong Server.
In thread329-880779 tsuji posted some code (timestamp 16 Jul 04 8:04) that looks like it'll do the job but my question is this. Which part of this line are variables that are specific to each Exchange/AD organisation?
Obviously, words such as [tt]strdb[/tt] & [tt]strstgrp[/tt] are variables but some of the others look like they could be assumptions (and thus could could vary from one domain to the next).
Could anyone show which parts are variables by highlighting them in red, please?
For comparison, here's my code, pretty much as taken from the Microsoft site (the FindAnyMDB function just seems to use the first storage group it finds, which is too presumptive for our needs).
Anyway, enough about me, how are you?
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
The script creates the account and the mailbox correctly (using cdoexm) but I need it to be more specific/flexible about where the mailbox get created. Specifically, we have an Exchange server in each of our three offices, London, Hong Kong and New York, so a Hong Kong user should have their mailbox on the Hong Kong Server.
In thread329-880779 tsuji posted some code (timestamp 16 Jul 04 8:04) that looks like it'll do the job but my question is this. Which part of this line are variables that are specific to each Exchange/AD organisation?
Code:
objMailbox.createMailbox "LDAP://CN=DB"& strdb & ","& strstgrp &",CN=InformationStore,CN=exchange server-"& strexsvr & ",CN=Servers,CN=my companydomain,CN=Administrative Groups,CN=my company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=intra,DC=my company,DC=com"
Could anyone show which parts are variables by highlighting them in red, please?
For comparison, here's my code, pretty much as taken from the Microsoft site (the FindAnyMDB function just seems to use the first storage group it finds, which is too presumptive for our needs).
Code:
Sub CreateMailbox
Dim objIADS
Dim strDefaultNC
Set objIADS = GetObject("LDAP://RootDSE")
strDefaultNC = objIADS.Get("defaultnamingcontext")
Set objIADSUser = GetObject("LDAP://CN=" & strUserName & "," & strOU & "," & strDefaultNC)
If objIADSUser Is Nothing then
MsgBox "The objIADSUser is Nothing."
Else
MsgBox "The objIADSUser is created successfully."
End If
Set objMailbox = objIADSUser
objMailbox.CreateMailbox FindAnyMDB("CN=Configuration," & strDefaultNC)
objIADSUser.Put "mailnickname","mailnickname" & strPre2kLogon
objIADSUser.SetInfo
End Sub
'-------------------------------------------------------------------------------
Function FindAnyMDB(strConfigurationNC)
wscript.echo "FindAnyMDB(" & strConfigurationNC & ")"
Dim objConnection
Dim objCommand
Dim objRecordSet
Dim strQuery
' Open the Connection.
Set objConnection = CreateObject("ADODB.Connection")
set objCommand = CreateObject("ADODB.Command")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "ADs Provider"
' Build the query to find the private MDB.
strQuery = "<LDAP://" & strConfigurationNC & ">;(objectCategory=msExchPrivateMDB);name,adspath;subtree"
objCommand.ActiveConnection = objConnection
wscript.echo "strQuery = '" & strQuery & "'"
objCommand.CommandText = strQuery
Set objRecordSet = objCommand.Execute
' If you have an MDB, return the first one.
If Not objRecordSet.EOF Then
objRecordSet.MoveFirst
FindAnyMDB = CStr(objRecordSet.Fields("ADsPath").Value)
Else
FindAnyMDB = ""
End If
'Clean up.
objRecordSet.Close
objConnection.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
End Function
Anyway, enough about me, how are you?
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]