account quick locking
This commit is contained in:
		
							parent
							
								
									922f54b172
								
							
						
					
					
						commit
						88238375ed
					
				|  | @ -2377,6 +2377,17 @@ class posixAccount extends baseModule implements passwordService { | |||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Returns if this account can be locked. | ||||
| 	 * This is the case if a hashed password is set ("{" at the beginning). | ||||
| 	 */ | ||||
| 	public function isLockable() { | ||||
| 		if (isset($this->attributes['userPassword'][0]) && ((substr($this->attributes['userPassword'][0], 0, 1) == "{") || (substr($this->attributes['userPassword'][0], 1, 1) == "{"))) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Returns if the Unix part of the current account is locked. | ||||
| 	 *  | ||||
|  | @ -2390,14 +2401,18 @@ class posixAccount extends baseModule implements passwordService { | |||
| 	 * Locks the user password of this account. | ||||
| 	 */ | ||||
| 	public function lock() { | ||||
| 		$this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]); | ||||
| 		if (isset($this->attributes['userPassword'][0])) { | ||||
| 			$this->attributes['userPassword'][0] = pwd_disable($this->attributes['userPassword'][0]); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Unlocks the user password of this account. | ||||
| 	 */ | ||||
| 	public function unlock() { | ||||
| 		$this->attributes['userPassword'][0] = pwd_enable($this->attributes['userPassword'][0]); | ||||
| 		if (isset($this->attributes['userPassword'][0])) { | ||||
| 			$this->attributes['userPassword'][0] = pwd_enable($this->attributes['userPassword'][0]); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|  |  | |||
|  | @ -2350,6 +2350,11 @@ class sambaSamAccount extends baseModule implements passwordService { | |||
| 	 */ | ||||
| 	public function deactivate() { | ||||
| 		$this->deactivated = true; | ||||
| 		$flags = $this->attributes['sambaAcctFlags'][0]; | ||||
| 		if (strpos($flags, 'D') === false) { | ||||
| 			$flags[strpos($flags, ' ')] = 'D'; | ||||
| 		} | ||||
| 		$this->attributes['sambaAcctFlags'][0] = $flags; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|  | @ -2357,6 +2362,8 @@ class sambaSamAccount extends baseModule implements passwordService { | |||
| 	 */ | ||||
| 	public function activate() { | ||||
| 		$this->deactivated = false; | ||||
| 		$this->attributes['sambaAcctFlags'][0] = str_replace('D', '', $this->attributes['sambaAcctFlags'][0]); | ||||
| 		$this->attributes['sambaAcctFlags'][0] = str_replace(']', ' ]', $this->attributes['sambaAcctFlags'][0]); | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
|  |  | |||
|  | @ -203,7 +203,7 @@ class user extends baseType { | |||
| 	 */ | ||||
| 	private function buildAccountStatusIcon($container) { | ||||
| 		// check if there are account parts that can be locked
 | ||||
| 		$unixAvailable = ($container->getAccountModule('posixAccount') != null); | ||||
| 		$unixAvailable = ($container->getAccountModule('posixAccount') != null) && $container->getAccountModule('posixAccount')->isLockable(); | ||||
| 		$sambaAvailable = (($container->getAccountModule('sambaSamAccount') != null) && $container->getAccountModule('sambaSamAccount')->isExtensionEnabled()); | ||||
| 		$ppolicyAvailable = ($container->getAccountModule('ppolicyUser') != null); | ||||
| 		if (!$unixAvailable && !$sambaAvailable && !$ppolicyAvailable) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue