102 : bool
103 {
104 $this->
logger->debug(sprintf(
105 'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
107 'soap'
108 ));
109 $this->
logger->debug(sprintf(
110 'Trying to find ext_account "%s" for auth_mode "%s".',
112 'soap'
113 ));
114
116 'soap',
118 );
119
120 $isNewUser = false;
121 if ('' === $internalLogin || null === $internalLogin) {
122 $isNewUser = true;
123 }
124
125 $soapAction = '';
126 $nspref = '';
127 if ($this->use_dot_net) {
128 $soapAction = $this->server_nms . '/isValidSession';
129 $nspref = 'ns1:';
130 }
131
133 'isValidSession',
134 [
137 $nspref . 'new_user' => $isNewUser
138 ],
139 $this->server_nms,
140 $soapAction
141 );
142
144 $valid = [
'valid' =>
false];
145 }
146
147 if (
$valid[
'valid'] !==
true) {
149 }
150
153 return false;
154 }
155
156 if (!$isNewUser) {
158 return true;
159 }
160
161 if (!$this->
settings->get(
'soap_auth_create_users')) {
162
164 return false;
165 }
166
169
170 $password = '';
172 if ($this->
settings->get(
'soap_auth_allow_local')) {
174 $password = $passwords[0];
176 }
177
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);
189
190 $userObj->setTimeLimitUnlimited(true);
191 $userObj->setTimeLimitFrom(time());
192 $userObj->setTimeLimitUntil(time());
193 $userObj->setOwner(0);
194 $userObj->create();
195 $userObj->setActive(true);
196 $userObj->updateOwner();
197 $userObj->saveAsNew();
198 $userObj->writePrefs();
199
200 $this->rbacAdmin->assignUser(
201 (
int) $this->
settings->get(
'soap_auth_user_default_role',
'4'),
202 $userObj->getId()
203 );
204
205 if ($this->
settings->get(
'soap_auth_account_mail',
'0')) {
207 $registrationSettings->setPasswordGenerationStatus(true);
208
210 $registrationSettings,
212 new NewAccountMailRepository($this->db)
213 );
214 $accountMail
215 ->withDirectRegistrationMode()
216 ->send($userObj, $password, false);
217 }
218
220 return true;
221 }
Class ilAccountRegistrationMail.
setReason(string $a_reason)
Set reason.
setAuthenticatedUserId(int $a_id)
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
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 ilObjAuthSettingsGUI.
static generatePasswords(int $a_number)
Generate a number of passwords.