Page 1 of 1 1
Topic Options
#153909 - 2005-12-22 04:35 PM how to create exchange mailbox
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Hi,

I've made a script that creates new users on our AD, but I don't know how to create the users exchange mailbox. Until now we have made it manually (using "Exchange Tasks") but is't there a way you can make KIX make the mailbox?

I've tried to see on the UDF library but I couldn't find anything

Jan

Top
#153910 - 2005-12-22 04:59 PM Re: how to create exchange mailbox
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Here is a script I use to bulk create accounts. It includes a section for creating a mailbox...

Code:

Break On

; Distinguished Name of the OU where you want to create the accounts
$objOU = GetObject("LDAP://OU=WI06,OU=Accounts,DC=your,DC=domain,DC=com")

; Tab-delimited text file containing the names for the accounts to create
$sUserList = @SCRIPTDIR+"\AD_WI06.txt"

If Not Open(1,$sUserList)
$sUser = ReadLine(1)
While Not @ERROR
$Err=''
$sUser = Split($sUser,Chr(9))
$sFullName = Trim(Join(Split($sUser[0],'"'),''))
$sLastName = Trim($sUser[1])
$sFrstName = Trim($sUser[2])
$sMdleName = Trim($sUser[3])
$sSAMName = Trim($sUser[4])

; General Tab
$objUser = $objOU.Create("User","cn="+Join(Split($sFullName,","),"\,"))
$objUser.Put("givenName",$sFrstName) ; First name
If Len($sMdleName) $objUser.Put("initials",$sMdleName) EndIf ; Middle initial
$objUser.Put("sn",$sLastName) ; Last name
$objUser.Put("displayName",$sFullName)
$objUser.Put("description","User Account")
$objUser.Put("physicalDeliveryOfficeName","MA07")
;$objUser.Put("telephoneNumber","")

; Account Tab
$objUser.Put("userPrincipalName",$sFrstName+"."+$sLastName+"@@domain.com")
$objUser.Put("sAMAccountName",$sSAMName)

; Profile Tab
$objUser.Put("scriptPath","rz_logon.bat")

; Telephones Tab
;$objUser.Put("homePhone","")

; Address Tab
$objUser.Put("c","US") ; Country
$objUser.Put("countryCode",840)
$objUser.Put("streetAddress","66 Sprague Street")
$objUser.Put("l","Hyde Park") ; City
$objUser.Put("st","MA") ; State
$objUser.Put("postalCode","02136")

; Create Mailbox
$msExchHomeServerName = "/O=domain/OU=World HQ/cn=Configuration/cn=Servers/cn=OH01MS42"
$homeMDB = "CN=OH01MS42 SG4 MS5,CN=OH01MS42 SG4,CN=InformationStore,CN=OH01MS42,"+
"CN=Servers,CN=World HQ,CN=Administrative Groups,CN=domain,CN=Microsoft "+
"Exchange,CN=Services,CN=Configuration,DC=domain,DC=com"
$objUser.Put("msExchHomeServerName",$msExchHomeServerName)
$objUser.Put("homeMDB",$homeMDB)
$objUser.Put("mDBUseDefaults",TRUE)
$objUser.Put("mailnickname",$sFrstName+"."+$sLastName)
$objUser.Put("mail",$sFrstName+"."+$sLastName+"@@domain.com")

; Commit changes to Active Directory
$objUser.SetInfo
If @ERROR $Err=$Err+','+@ERROR EndIf

; Set the password
$objUser.SetPassword("domain1")
If @ERROR $Err=$Err+','+@ERROR EndIf

; Enable "Change password on next logon" flag
$objUser.Put("userAccountControl","512")
$objUser.Put("pwdLastSet",0)
$objUser.SetInfo
If @ERROR $Err=$Err+','+@ERROR EndIf

; Place the user in the appropriate groups (must have DN of the groups)
$objGroup = GetObject("LDAP://CN=group,OU=Accounts,DC=your,DC=domain,DC=com")
$objGroup.Add($objUser.ADsPath)
If @ERROR $Err=$Err+','+@ERROR EndIf

$objGroup = GetObject("LDAP://CN=distributionList,OU=Distribution Lists,OU=Exchange,DC=your,DC=domain,DC=com")
$objGroup.Add($objUser.ADsPath)
If @ERROR $Err=$Err+','+@ERROR EndIf

$sFullName + " " + $Err ?

$sUser = ReadLine(1)
Loop
Else
"Error "+@SERROR+" opening "+$Database ?
Exit
EndIf

Get $

Exit 0


Top
#153911 - 2005-12-23 02:30 PM Re: how to create exchange mailbox
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Thanks alot. I works :-)
Top
#153912 - 2006-08-29 05:59 PM Re: how to create exchange mailbox
Gerald_G Offline
Fresh Scripter

Registered: 2005-04-11
Posts: 34
Loc: Canada
Quote:

Here is a script I use to bulk create accounts. It includes a section for creating a mailbox...

Code:

; Create Mailbox
$msExchHomeServerName = "/O=domain/OU=World HQ/cn=Configuration/cn=Servers/cn=OH01MS42"
$homeMDB = "CN=OH01MS42 SG4 MS5,CN=OH01MS42 SG4,CN=InformationStore,CN=OH01MS42,"+
"CN=Servers,CN=World HQ,CN=Administrative Groups,CN=domain,CN=Microsoft "+
"Exchange,CN=Services,CN=Configuration,DC=domain,DC=com"
$objUser.Put("msExchHomeServerName",$msExchHomeServerName)
$objUser.Put("homeMDB",$homeMDB)
$objUser.Put("mDBUseDefaults",TRUE)
$objUser.Put("mailnickname",$sFrstName+"."+$sLastName)
$objUser.Put("mail",$sFrstName+"."+$sLastName+"@@domain.com")

; Commit changes to Active Directory
$objUser.SetInfo
If @ERROR $Err=$Err+','+@ERROR EndIf

Exit 0






Can someone further explain the meanings of this section for me ?
I'm trying to figure out the /O and the CN= sections of the exchange server and home database lines.

I'd appreciate any further details.

gerald

Top
#153913 - 2006-08-29 06:48 PM Re: how to create exchange mailbox
Gerald_G Offline
Fresh Scripter

Registered: 2005-04-11
Posts: 34
Loc: Canada
Never mind - I think I found some help. Using LDIFDE to do an export, I was able to find the values of my installation.

LDIFDE –F [output file] –D [domain and/or container name] –L [attributes to export] –R [LDAP query filter for the database]

For example:

LDIFDE –F EXPORT-EXCHANGE1.TXT –D “DC=contoso,DC=com” –L msExchHomeServerName,homeMDB,homeMTA –R “(homeMDB=CN=DB1,CN=SG1,CN=InformationStore,CN=Exchange1,CN=Servers,CN=AG1,CN=Administrative Groups,CN=Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=contoso,DC=com)”

Top
#153914 - 2006-08-31 03:57 PM Re: how to create exchange mailbox
Kaiminator Offline
Fresh Scripter

Registered: 2006-08-28
Posts: 17
Quote:

Hi,

I've made a script that creates new users on our AD, but I don't know how to create the users exchange mailbox. Until now we have made it manually (using "Exchange Tasks") but is't there a way you can make KIX make the mailbox?

I've tried to see on the UDF library but I couldn't find anything

Jan




This is exactly my goal, what i wanted to do ;-) Can you paste your code here, so that the comunity gets benefit of it ;-)

Top
#153915 - 2006-08-31 04:20 PM Re: how to create exchange mailbox
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I think the community is benefitting by reading the FAQs
Anyway, there is a description over there.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.054 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org