src/Classes/AdldapExchange.php
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);
    }
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);
    }
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 ) ; }
Create an Exchange account.

@param string $username     The username of the user to add the Exchange account to
@param array  $storageGroup The mailbox, Exchange Storage Group, for the user account, this must be a full CN
@param string $emailAddress The primary email address to add to this user
@param null   $mailNickname The mail nick name. If mail nickname is blank, the username will be used
@param bool   $useDefaults  Indicates whether the store should use the default quota, rather than the per-mailbox quota.
@param null   $baseDn       Specify an alternative base_dn for the Exchange storage group
@param bool   $isGUID       Is the username passed a GUID or a samAccountName

@return bool|string

@throws AdldapException
Create an Exchange account .