为AD设置msExchMailboxGuid

I'm trying to create an Exchange 2010 mailbox using php. I've read a thread that mentions msExchMailboxGuid is required to create the mailbox. I'm using adLDAP as a wrapper around the ldap functionality.

I'm generating a guid fine, I just can't figure out how to send it so AD likes it. I am sending it the same way the format should be to search using a guid as a hex string, which I can do without a problem.

When attempting to set that attribute, I get a Constraint violation for that field, which from searching seems to be a length issue.

Here's my guid:

66caeefb-dfc0-4f30-8d83-6b4d4d6198cf

Here it is in UTF-8 hex:

\fb\ee\ca\66\c0\df\30\4f\8d\83\6b\4d\4d\61\98\cf

I've tried it as unencoded, with slashes, without slashes, with slashes escaped, plain string guid, plain string guid without dashes... How can I send it so it will be accepted?

If I don't include msExchMailboxGuid, the AD account gets created successfully but no mailbox exists.

Active Directory is expecting msExchMailboxGuid to be a binary value when creating/modifying users. You were on the right track with the hex value. Take the hex without slashes and pass it to hex2bin:

$mailboxGuid = hex2bin('fbeeca66c0df304f8d836b4d4d6198cf');

However, you'll probably run into more issues than just the GUID. If you're willing to use a separate library, it's possible to create Exchange Mailboxes (Exchange 2010 - 2016) using the LdapTools library:

https://github.com/ldaptools/ldaptools/blob/master/docs/en/cookbook/Creating-Exchange-Mailboxes.md

I would suggest the newer AdLdap2 library, but I don't think it supports Exchange stuff anymore natively in the library.