19declare(strict_types=1);
31 protected string $uri =
'';
44 $this->
logger = $DIC->logger()->auth();
46 $this->rbacAdmin =
$DIC->rbac()->admin();
47 $this->db =
$DIC->database();
54 $this->server_host = (string) $this->
settings->get(
'soap_auth_server',
'');
55 $this->server_port = (string) $this->
settings->get(
'soap_auth_port',
'');
56 $this->server_uri = (string) $this->
settings->get(
'soap_auth_uri',
'');
57 $this->server_nms = (string) $this->
settings->get(
'soap_auth_namespace',
'');
58 $this->server_https = (bool) $this->
settings->get(
'soap_auth_use_https',
'0');
59 $this->use_dot_net = (bool) $this->
settings->get(
'use_dotnet',
'0');
61 $this->uri = $this->server_https ?
'https://' :
'http://';
64 if ($this->server_port > 0) {
67 if ($this->server_uri) {
71 require_once __DIR__ .
'/../../soap/lib/nusoap.php';
83 }
catch (Exception
$e) {
84 $this->
getLogger()->error($e->getMessage());
85 $this->
getLogger()->error($e->getTraceAsString());
90 $this->
logger->info(
'Successfully authenticated user via SOAP: ' . $this->
getCredentials()->getUsername());
104 $this->
logger->debug(sprintf(
105 'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
109 $this->
logger->debug(sprintf(
110 'Trying to find ext_account "%s" for auth_mode "%s".',
121 if (
'' === $internalLogin ||
null === $internalLogin) {
127 if ($this->use_dot_net) {
128 $soapAction = $this->server_nms .
'/isValidSession';
137 $nspref .
'new_user' => $isNewUser
144 $valid = [
'valid' =>
false];
147 if (
$valid[
'valid'] !==
true) {
161 if (!$this->
settings->get(
'soap_auth_create_users')) {
172 if ($this->
settings->get(
'soap_auth_allow_local')) {
174 $password = $passwords[0];
178 $userObj->setLogin($internalLogin);
179 $userObj->setFirstname($user->getFirstname());
180 $userObj->setLastname($user->getLastname());
181 $userObj->setTitle($userObj->getFullname());
182 $userObj->setDescription($userObj->getEmail());
183 $userObj->setEmail($user->getEmail());
184 $userObj->setPasswd($password, $password_type);
185 $userObj->setAuthMode(
'soap');
186 $userObj->setExternalAccount($this->
getCredentials()->getUsername());
187 $userObj->setLanguage($this->
language->getDefaultLanguage());
188 $userObj->setProfileIncomplete(
true);
190 $userObj->setTimeLimitUnlimited(
true);
191 $userObj->setTimeLimitFrom(time());
192 $userObj->setTimeLimitUntil(time());
193 $userObj->setOwner(0);
195 $userObj->setActive(
true);
196 $userObj->updateOwner();
197 $userObj->saveAsNew();
198 $userObj->writePrefs();
200 $this->rbacAdmin->assignUser(
201 (
int) $this->
settings->get(
'soap_auth_user_default_role',
'4'),
205 if ($this->
settings->get(
'soap_auth_account_mail',
'0')) {
207 $registrationSettings->setPasswordGenerationStatus(
true);
210 $registrationSettings,
212 new NewAccountMailRepository($this->db)
215 ->withDirectRegistrationMode()
216 ->send($userObj, $password,
false);
Class ilAccountRegistrationMail.
handleSoapAuth(ilAuthStatus $status)
doAuthentication(ilAuthStatus $status)
@inheritDoc
__construct(ilAuthCredentials $credentials)
ilAuthCredentials $credentials
setTranslatedReason(string $a_reason)
Set translated reason.
const int STATUS_AUTHENTICATION_FAILED
setReason(string $a_reason)
Set reason.
setAuthenticatedUserId(int $a_id)
setStatus(int $a_status)
Set auth status.
const int STATUS_AUTHENTICATED
getAuthenticatedUserId()
Get authenticated user id.
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
Component logger with individual log levels by component id.
static _lookupId(string|array $a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
Class ilRbacAdmin Core functions for role based access control.
Class ilObjAuthSettingsGUI.
static generatePasswords(int $a_number)
Generate a number of passwords.
static set(string $a_var, $a_val)
Set a value.
[nu]soapclient higher level class for easy usage.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc