Skip to content

Instantly share code, notes, and snippets.

@Feiron
Created March 3, 2026 09:30
Show Gist options
  • Select an option

  • Save Feiron/640de43163923f71ffd6e9f466a97104 to your computer and use it in GitHub Desktop.

Select an option

Save Feiron/640de43163923f71ffd6e9f466a97104 to your computer and use it in GitHub Desktop.
[Смена пароля и ресет] Смена пароля так же разлогинет человека #bitrix#utils#password
<?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>';
}
$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