Accessing Microsoft Exchange Server from Ruby

Accessing Microsoft Exchange server from Ruby

One place to start would be the Exchange Developer Center, where Microsoft links to downloads of the different SDKs, documentation, etc. Understandably, most of the docs and examples will be using Microsoft's .NET Framework and languages.

If you want to connect with Exchange 2007 or 2010, you'll probably find it easiest to use some form of Exchange Web Services (EWS) which you may be able to connect to using Ruby web services frameworks like SOAP4R, WSO2, etc.

For Exchange 2003 and earlier, you're much more limited; and programming CDO through Ruby's win32ole is not going to be pretty or fun.

Ruby on Rails error using SMTP Microsoft Exchange mail account

Try to send an email via telnet at first. Then check which error message you get. Based on that test you can then build the needed configure.

As discussed in the comments already "plaintext authentication" might be the best option but you can find that out via telnet.

Run Exchange Powershell commands from Linux using Ruby/WinRM

We managed to get it to work. I had to first connect to a 'management' server to initiate the powershell command.

endpoint = 'http://YOURSERVER:5985/wsman'
krb5_realm = 'YOURREALM'
winrm = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => krb5_realm)

Then I had to modify the exchange command to this:

exch_cmd = "Enable-Mailbox -Identity:'DOMAIN/OU/#{fullname}' -Alias:'#{username}' -Database:'#{MailboxDB}'"

command = "powershell -NonInteractive -WindowStyle Hidden -command \" $username = '#{account}'; $password = ConvertTo-SecureString '#{password}' -asplaintext -force; $UserCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username,$password; $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri #{server} -Authentication Kerberos -Credential $UserCredential; Invoke-Command -Session $Session {#{exch_cmd}}\""

On the Management and Exchange servers, the service account needs to be in the Remote Management Group. You also need to update the SDDL according to this guide: http://www.sevecek.com/Lists/Posts/Post.aspx?ID=280 Depending on your server config this will be different.



Related Topics



Leave a reply



Submit