@@ -125,7 +125,7 @@ public function __construct($username, $dn, Access $access,
125125 IConfig $ config , FilesystemHelper $ fs , Image $ image ,
126126 LogWrapper $ log , IAvatarManager $ avatarManager , IUserManager $ userManager ,
127127 INotificationManager $ notificationManager ) {
128-
128+
129129 if ($ username === null ) {
130130 $ log ->log ("uid for ' $ dn' must not be null! " , ILogger::ERROR );
131131 throw new \InvalidArgumentException ('uid must not be null! ' );
@@ -712,36 +712,34 @@ public function handlePasswordExpiry($params) {
712712 if (isset ($ uid ) && $ uid === $ this ->getUsername ()) {
713713 //retrieve relevant user attributes
714714 $ result = $ this ->access ->search ('objectclass=* ' , array ($ this ->dn ), ['pwdpolicysubentry ' , 'pwdgraceusetime ' , 'pwdreset ' , 'pwdchangedtime ' ]);
715-
715+
716716 if (array_key_exists ('pwdpolicysubentry ' , $ result [0 ])) {
717717 $ pwdPolicySubentry = $ result [0 ]['pwdpolicysubentry ' ];
718718 if ($ pwdPolicySubentry && (count ($ pwdPolicySubentry ) > 0 )){
719719 $ ppolicyDN = $ pwdPolicySubentry [0 ];//custom ppolicy DN
720720 }
721721 }
722-
723- $ pwdGraceUseTime = array_key_exists ('pwdgraceusetime ' , $ result [0 ]) ? $ result [0 ]['pwdgraceusetime ' ] : null ;
724- $ pwdReset = array_key_exists ('pwdreset ' , $ result [0 ]) ? $ result [0 ]['pwdreset ' ] : null ;
725- $ pwdChangedTime = array_key_exists ('pwdchangedtime ' , $ result [0 ]) ? $ result [0 ]['pwdchangedtime ' ] : null ;
726-
722+
723+ $ pwdGraceUseTime = array_key_exists ('pwdgraceusetime ' , $ result [0 ]) ? $ result [0 ]['pwdgraceusetime ' ] : [] ;
724+ $ pwdReset = array_key_exists ('pwdreset ' , $ result [0 ]) ? $ result [0 ]['pwdreset ' ] : [] ;
725+ $ pwdChangedTime = array_key_exists ('pwdchangedtime ' , $ result [0 ]) ? $ result [0 ]['pwdchangedtime ' ] : [] ;
726+
727727 //retrieve relevant password policy attributes
728728 $ cacheKey = 'ppolicyAttributes ' . $ ppolicyDN ;
729729 $ result = $ this ->connection ->getFromCache ($ cacheKey );
730730 if (is_null ($ result )) {
731731 $ result = $ this ->access ->search ('objectclass=* ' , array ($ ppolicyDN ), ['pwdgraceauthnlimit ' , 'pwdmaxage ' , 'pwdexpirewarning ' ]);
732732 $ this ->connection ->writeToCache ($ cacheKey , $ result );
733733 }
734-
735- $ pwdGraceAuthNLimit = array_key_exists ('pwdgraceauthnlimit ' , $ result [0 ]) ? $ result [0 ]['pwdgraceauthnlimit ' ] : null ;
736- $ pwdMaxAge = array_key_exists ('pwdmaxage ' , $ result [0 ]) ? $ result [0 ]['pwdmaxage ' ] : null ;
737- $ pwdExpireWarning = array_key_exists ('pwdexpirewarning ' , $ result [0 ]) ? $ result [0 ]['pwdexpirewarning ' ] : null ;
738-
734+
735+ $ pwdGraceAuthNLimit = array_key_exists ('pwdgraceauthnlimit ' , $ result [0 ]) ? $ result [0 ]['pwdgraceauthnlimit ' ] : [] ;
736+ $ pwdMaxAge = array_key_exists ('pwdmaxage ' , $ result [0 ]) ? $ result [0 ]['pwdmaxage ' ] : [] ;
737+ $ pwdExpireWarning = array_key_exists ('pwdexpirewarning ' , $ result [0 ]) ? $ result [0 ]['pwdexpirewarning ' ] : [] ;
738+
739739 //handle grace login
740- $ pwdGraceUseTimeCount = count ($ pwdGraceUseTime );
741- if ($ pwdGraceUseTime && $ pwdGraceUseTimeCount > 0 ) { //was this a grace login?
742- if ($ pwdGraceAuthNLimit
743- && (count ($ pwdGraceAuthNLimit ) > 0 )
744- &&($ pwdGraceUseTimeCount < (int )$ pwdGraceAuthNLimit [0 ])) { //at least one more grace login available?
740+ if (!empty ($ pwdGraceUseTime )) { //was this a grace login?
741+ if (!empty ($ pwdGraceAuthNLimit ))
742+ && count ($ pwdGraceUseTime ) < (int )$ pwdGraceAuthNLimit [0 ])) { //at least one more grace login available?
745743 $ this ->config ->setUserValue ($ uid , 'user_ldap ' , 'needsPasswordReset ' , 'true ' );
746744 header ('Location: ' .\OC ::$ server ->getURLGenerator ()->linkToRouteAbsolute (
747745 'user_ldap.renewPassword.showRenewPasswordForm ' , array ('user ' => $ uid )));
@@ -752,16 +750,16 @@ public function handlePasswordExpiry($params) {
752750 exit ();
753751 }
754752 //handle pwdReset attribute
755- if ( $ pwdReset && ( count ($ pwdReset) > 0 ) && $ pwdReset [0 ] === 'TRUE ' ) { //user must change his password
753+ if (! empty ($ pwdReset ) && $ pwdReset [0 ] === 'TRUE ' ) { //user must change his password
756754 $ this ->config ->setUserValue ($ uid , 'user_ldap ' , 'needsPasswordReset ' , 'true ' );
757755 header ('Location: ' .\OC ::$ server ->getURLGenerator ()->linkToRouteAbsolute (
758756 'user_ldap.renewPassword.showRenewPasswordForm ' , array ('user ' => $ uid )));
759757 exit ();
760758 }
761759 //handle password expiry warning
762- if ( $ pwdChangedTime && ( count ($ pwdChangedTime) > 0 )) {
763- if ( $ pwdMaxAge && ( count ($ pwdMaxAge) > 0 )
764- && $ pwdExpireWarning && ( count ( $ pwdExpireWarning) > 0 )) {
760+ if (! empty ($ pwdChangedTime )) {
761+ if (! empty ($ pwdMaxAge )
762+ && ! empty ( $ pwdExpireWarning )) {
765763 $ pwdMaxAgeInt = (int )$ pwdMaxAge [0 ];
766764 $ pwdExpireWarningInt = (int )$ pwdExpireWarning [0 ];
767765 if ($ pwdMaxAgeInt > 0 && $ pwdExpireWarningInt > 0 ){
@@ -782,7 +780,7 @@ public function handlePasswordExpiry($params) {
782780 $ notification ->setApp ('user_ldap ' )
783781 ->setUser ($ uid )
784782 ->setDateTime ($ currentDateTime )
785- ->setObject ('pwd_exp_warn ' , $ uid )
783+ ->setObject ('pwd_exp_warn ' , $ uid )
786784 ->setSubject ('pwd_exp_warn_days ' , [(int ) ceil ($ secondsToExpiry / 60 / 60 / 24 )])
787785 ;
788786 $ this ->notificationManager ->notify ($ notification );
0 commit comments