public function testValidationFailsStorageGroup() { $attributes = ['username' => 'Jdoe', 'storageGroup' => 'Invalid Storage Group', 'emailAddress' => '*****@*****.**']; $mailbox = new Mailbox($attributes); $this->setExpectedException('Adldap\\Exceptions\\AdldapException'); $mailbox->validateRequired(); }
public function createMailbox($username, $storageGroup, $emailAddress, $mailNickname = null, $useDefaults = true, $baseDn = null, $isGUID = false) { $mailbox = new Mailbox(['username' => $username, 'storageGroup' => $storageGroup, 'emailAddress' => $emailAddress, 'mailNickname' => $mailNickname, 'baseDn' => $baseDn ? $baseDn : $this->adldap->getBaseDn(), 'mdbUseDefaults' => $this->adldap->utilities()->boolToStr($useDefaults)]); // Validate the mailbox fields $mailbox->validateRequired(); // Set the container attribute by imploding the storage group array $mailbox->setAttribute('container', 'CN=' . implode(',CN=', $storageGroup)); // Set the mail nickname to the username if it isn't provided if ($mailbox->{'mailNickname'} === null) { $mailbox->setAttribute('mailNickname', $mailbox->{'username'}); } // Perform the creation and return the result return $this->adldap->user()->modify($username, $mailbox->toLdapArray(), $isGUID); }