src/Classes/AdldapUsers.php
public function passwordExpiry($username)
    {
        $this->adldap->utilities()->validateBcmodExists();

        $user = $this->info($username, ['pwdlastset', 'useraccountcontrol']);

        if (is_array($user) && array_key_exists('pwdlastset', $user)) {
            $pwdLastSet = $user['pwdlastset'];

            $status = [
                'expires' => true,
                'has_expired' => false,
            ];

            // Check if the password expires
            if (array_key_exists('useraccountcontrol', $user) && $user['useraccountcontrol'] == '66048') {
                $status['expires'] = false;
            }

            // Check if the password is expired
            if ($pwdLastSet === '0') {
                $status['has_expired'] = true;
            }

            $result = $this->adldap->search()
                ->select(['maxPwdAge'])
                ->where('objectclass', '*')
                ->first();

            if ($result && $status['expires'] === true) {
                $maxPwdAge = $result['maxpwdage'];

                // See MSDN: http://msdn.microsoft.com/en-us/library/ms974598.aspx
                if (bcmod($maxPwdAge, 4294967296) === '0') {
                    return 'Domain does not expire passwords';
                }

                // Add maxpwdage and pwdlastset and we get password expiration time in Microsoft's
                // time units.  Because maxpwd age is negative we need to subtract it.
                $pwdExpire = bcsub($pwdLastSet, $maxPwdAge);

                // Convert MS's time to Unix time
                $unixTime = bcsub(bcdiv($pwdExpire, '10000000'), '11644473600');

                $status['expiry_timestamp'] = $unixTime;
                $status['expiry_formatted'] = date('Y-m-d H:i:s', $unixTime);
            }

            return $status;
        }

        return false;
    }
public function passwordExpiry($username)
    {
        $this->adldap->utilities()->validateBcmodExists();

        $user = $this->info($username, ['pwdlastset', 'useraccountcontrol']);

        if (is_array($user) && array_key_exists('pwdlastset', $user)) {
            $pwdLastSet = $user['pwdlastset'];

            $status = [
                'expires' => true,
                'has_expired' => false,
            ];

            // Check if the password expires
            if (array_key_exists('useraccountcontrol', $user) && $user['useraccountcontrol'] == '66048') {
                $status['expires'] = false;
            }

            // Check if the password is expired
            if ($pwdLastSet === '0') {
                $status['has_expired'] = true;
            }

            $result = $this->adldap->search()
                ->select(['maxPwdAge'])
                ->where('objectclass', '*')
                ->first();

            if ($result && $status['expires'] === true) {
                $maxPwdAge = $result['maxpwdage'];

                // See MSDN: http://msdn.microsoft.com/en-us/library/ms974598.aspx
                if (bcmod($maxPwdAge, 4294967296) === '0') {
                    return 'Domain does not expire passwords';
                }

                // Add maxpwdage and pwdlastset and we get password expiration time in Microsoft's
                // time units.  Because maxpwd age is negative we need to subtract it.
                $pwdExpire = bcsub($pwdLastSet, $maxPwdAge);

                // Convert MS's time to Unix time
                $unixTime = bcsub(bcdiv($pwdExpire, '10000000'), '11644473600');

                $status['expiry_timestamp'] = $unixTime;
                $status['expiry_formatted'] = date('Y-m-d H:i:s', $unixTime);
            }

            return $status;
        }

        return false;
    }
public function passwordExpiry ( $ username ) { $ this -> adldap -> utilities ( ) -> validateBcmodExists ( ) ; $ user = $ this -> info ( $ username , [ 'pwdlastset' , 'useraccountcontrol' ] ) ; if ( is_array ( $ user ) && array_key_exists ( 'pwdlastset' , $ user ) ) { $ pwdLastSet = $ user [ 'pwdlastset' ] ; $ status = [ 'expires' => true , 'has_expired' => false , ] ; // Check if the password expires if ( array_key_exists ( 'useraccountcontrol' , $ user ) && $ user [ 'useraccountcontrol' ] == '66048' ) { $ status [ 'expires' ] = false ; } // Check if the password is expired if ( $ pwdLastSet === '0' ) { $ status [ 'has_expired' ] = true ; } $ result = $ this -> adldap -> search ( ) -> select ( [ 'maxPwdAge' ] ) -> where ( 'objectclass' , '*' ) -> first ( ) ; if ( $ result && $ status [ 'expires' ] === true ) { $ maxPwdAge = $ result [ 'maxpwdage' ] ; // See MSDN: http://msdn.microsoft.com/en-us/library/ms974598.aspx if ( bcmod ( $ maxPwdAge , 4294967296 ) === '0' ) { return 'Domain does not expire passwords' ; } // Add maxpwdage and pwdlastset and we get password expiration time in Microsoft's // time units.  Because maxpwd age is negative we need to subtract it. $ pwdExpire = bcsub ( $ pwdLastSet , $ maxPwdAge ) ; // Convert MS's time to Unix time $ unixTime = bcsub ( bcdiv ( $ pwdExpire , '10000000' ) , '11644473600' ) ; $ status [ 'expiry_timestamp' ] = $ unixTime ; $ status [ 'expiry_formatted' ] = date ( 'Y-m-d H:i:s' , $ unixTime ) ; } return $ status ; } return false ; }
Determine a user's password expiry date.

@param $username

@return array|bool

@throws AdldapException
@requires bcmod http://php.net/manual/en/function.bcmod.php
Determine a user s password expiry date .