Php – Creating a user on exchange through LDAP

exchangeldapPHP

I have managed to use the LDAP module that comes standard with PHP to find, add, modify, and authenticate user accounts and groups to Active Directory.

The only thing that has me stumped is creating a mailbox for a new user in exchange.

Now I notice that people point to ews, adLDAP, ldaptools.

I am wondering if it is possible to just use LDAP to accomplish this goal. Has anyone attempted this?

Also when adding user mailboxs in exchange, back-end uses load balancing and automatically distributes the accounts between the available DBs, can this be utilized when adding user mailboxes with php?

Is this even possible through plain LDAP? if not what are my choices?

Response to BastianW:

I have tried using power-shell and executing it from my php script:

1- php script resides on a webserver

2-exchange resides on another server

3-the command I built to execute on remote-exchange:

$command1 =  'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command'. ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell; enable-mailuser -identity tmeow@comp.com -ExternalEmailAddress tmeow@comp.com";
shell_exec($command1);

I can run this in power-shell with no problem, but in php I can not run it successfully.

Best Answer

You can't use LDAP to create an Exchange Mailbox. The main reason is that the user will get an Exchange Mailbox GUI ID which can only be generated by the Exchange Subsystem (e.g. via PowerShell).
You can't fake that one and add some random fields via LDAP.

However there are some possible options for you:

  1. You could use EWS there is also a php EWS module build.
  2. You could build a webservice which is triggering some PowerShell scripts and include the webserver inside your PHP script. This is how I build a construct for multiple companies to automate their Exchange processes.
Related Topic