Creating Exchange mailBox via Ruby?

Howdy!

I am setting up services that automagically provision a new portal user
with things like filespace, and an Exchange mailbox. The filespace is
easy, but I have not found any way to do the Exchange part. I have
many vbscript examples, but that does not help me any if ruby cannot do
what vbs can. So the question is:

Can Ruby interact with Exchange Information Stores, by creating
mailboxes, changing mailbox properties and the like?

The vbs examples look like they use LDAP to connect and interact, but
the methods that are used seem to be specific to vbs. Any one with any
experience with this?

PS. I know that I can use vbs, but our setup would require the scripts
to be run on a DC, and I would like to avoid that type of dependance.

I am looking into ADSI now… wondering if I can do almost the exact
same stuff in ruby as what I found in vbs…

On 12/8/05, [email protected] [email protected] wrote:

mailboxes, changing mailbox properties and the like?

The vbs examples look like they use LDAP to connect and interact, but
the methods that are used seem to be specific to vbs. Any one with any
experience with this?

PS. I know that I can use vbs, but our setup would require the scripts
to be run on a DC, and I would like to avoid that type of dependance.

Sure it can. Check out the Win32OLE library. It allows you to make all
of
the same calls you would in VBScript, in Ruby. I don’t have a link off
hand, but if you used the ruby installer for win32 you’ve already got
it.

On 12/8/05, [email protected] [email protected] wrote:

I have found that I can do all the normal stuff, but interaction with
exchange is via CDOEXM.DLL, and I still have to see if WIn32OLE will do
that part as well. I can return all the user properties, and even the
HomeMDB which is the full path to the user’s mailbox, but I have not
had any success with CreateMailbox. I am thinking that I may have to
do it on the server for it to have access to the right DLL.

Really the only difference between performing this task in Ruby versus
doing
it in VBScript is that you get to use Ruby :slight_smile: Otherwise the same
restrictions still apply. The COM Objects still have to reside locally
unless you’re doing some DCOM mojo. To my knowledge though CDO has to
be
installed locally, but that doesn’t mean it has to be run from the
Exchange
server. I’ve seen automated Exchange creation run via a VBScript on a
member server in the domain, as opposed to directly on the Exchange box.
You just need to make sure you get CDO and all of that installed on the
box
you want to do the creation from.

I have the Exchange Management Tools installed, and I can do a little
more than before. I can query and set attributes, but I cannot
actually create a mailbox or set store defaults on existing mail boxws.
It tells me it is an invalid method in both cases.

Here is the bit of code:

usr =WIN32OLE.connect("LDAP://CN=" + @login + cont)
	usr.CreateMailbox("LDAP://" + mBox )
	usr.EnableStoreDefaults = TRUE
	usr.AccountDisabled = FALSE
	usr.SetInfo
	usr.put "protocolsettings" , "POP3§0§1§4§ISO-8859-1§0§§§"
	usr.setinfo

I would really love to be able to do this in Ruby, since cscript takes
so land to start it adds 10+ seconds to the operation.

I have found that I can do all the normal stuff, but interaction with
exchange is via CDOEXM.DLL, and I still have to see if WIn32OLE will do
that part as well. I can return all the user properties, and even the
HomeMDB which is the full path to the user’s mailbox, but I have not
had any success with CreateMailbox. I am thinking that I may have to
do it on the server for it to have access to the right DLL.