Created
March 3, 2026 09:30
-
-
Save Feiron/640de43163923f71ffd6e9f466a97104 to your computer and use it in GitHub Desktop.
[Смена пароля и ресет] Смена пароля так же разлогинет человека #bitrix#utils#password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| define('STOP_STATISTICS', true); | |
| define('BX_SECURITY_SHOW_MESSAGE', true); | |
| define("NOT_CHECK_PERMISSIONS", true); | |
| $_SERVER['DOCUMENT_ROOT'] = '/home/bitrix/www'; | |
| require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); | |
| $arFilter = ['ACTIVE' => 'Y']; | |
| $dbUsers = \Bitrix\Main\UserTable::getList(['filter' => $arFilter]); | |
| echo '<pre>'; | |
| var_dump($dbUsers->getSelectedRowsCount()); | |
| echo '</pre>'; | |
| foreach ($dbUsers as $arUser) { | |
| $userId = $arUser['ID']; | |
| if($userId == XXX){ | |
| //echo '<pre>'; var_dump('Скип себя'); echo '</pre>'; | |
| continue; | |
| } | |
| $password = \CUser::GeneratePasswordByPolicy([11]); | |
| $user = new \CUser(); | |
| $fields = [ | |
| "PASSWORD" => $password, | |
| "CONFIRM_PASSWORD" => $password | |
| ]; | |
| $user->Update($userId, $fields); | |
| echo implode(' ', [$arUser['LOGIN'], $password]); | |
| echo '<br>'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $userId = XX; | |
| \Bitrix\Main\UserAuthActionTable::addLogoutAction($userId); | |
| // Удаляем пароли приложений (desktop, mobile) досим AD неверным паролем - он блочит учетку | |
| $passwordsList = \Bitrix\Main\Authentication\ApplicationPasswordTable::getList([ | |
| "filter" => [ | |
| "=USER_ID" => $userId, | |
| "=APPLICATION_ID" => ["desktop", "mobile"], | |
| ], | |
| ]); | |
| while ($password = $passwordsList->fetch()) { | |
| \Bitrix\Main\Authentication\ApplicationPasswordTable::delete($password["ID"]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment