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());
93 $this->
logger->info(
'Successfully authenticated user via SOAP: ' . $this->
getCredentials()->getUsername());
107 $this->
logger->debug(sprintf(
108 'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
112 $this->
logger->debug(sprintf(
113 'Trying to find ext_account "%s" for auth_mode "%s".',
124 if (
'' === $internalLogin ||
null === $internalLogin) {
130 if ($this->use_dot_net) {
131 $soapAction = $this->server_nms .
'/isValidSession';
140 $nspref .
'new_user' => $isNewUser
147 $valid = [
'valid' =>
false];
150 if (
$valid[
'valid'] !==
true) {
164 if (!$this->
settings->get(
'soap_auth_create_users')) {
175 if ($this->
settings->get(
'soap_auth_allow_local')) {
177 $password = $passwords[0];
181 $userObj->setLogin($internalLogin);
182 $userObj->setFirstname($user->getFirstname());
183 $userObj->setLastname($user->getLastname());
184 $userObj->setTitle($userObj->getFullname());
185 $userObj->setDescription($userObj->getEmail());
186 $userObj->setEmail($user->getEmail());
187 $userObj->setPasswd($password, $password_type);
188 $userObj->setAuthMode(
'soap');
189 $userObj->setExternalAccount($this->
getCredentials()->getUsername());
190 $userObj->setLanguage($this->
language->getDefaultLanguage());
191 $userObj->setProfileIncomplete(
true);
193 $userObj->setTimeLimitUnlimited(
true);
194 $userObj->setTimeLimitFrom(time());
195 $userObj->setTimeLimitUntil(time());
196 $userObj->setOwner(0);
198 $userObj->setActive(
true);
199 $userObj->updateOwner();
200 $userObj->saveAsNew();
201 $userObj->writePrefs();
203 $this->rbacAdmin->assignUser(
204 (
int) $this->
settings->get(
'soap_auth_user_default_role',
'4'),
208 if ($this->
settings->get(
'soap_auth_account_mail',
'0')) {
210 $registrationSettings->setPasswordGenerationStatus(
true);
213 $registrationSettings,
215 new NewAccountMailRepository($this->db)
218 ->withDirectRegistrationMode()
219 ->send($userObj, $password,
false);
Class ilAccountRegistrationMail.
handleSoapAuth(ilAuthStatus $status)
doAuthentication(ilAuthStatus $status)
@inheritDoc
__construct(ilAuthCredentials $credentials)
handleAuthenticationFail(ilAuthStatus $status, string $a_reason)
ilAuthCredentials $credentials
setTranslatedReason(string $a_reason)
Set translated reason.
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