100 : bool
101 {
102 $this->
logger->debug(sprintf(
103 'Login observer called for SOAP authentication request of ext_account "%s" and auth_mode "%s".',
105 'soap'
106 ));
107 $this->
logger->debug(sprintf(
108 'Trying to find ext_account "%s" for auth_mode "%s".',
110 'soap'
111 ));
112
114 'soap',
116 );
117
118 $isNewUser = false;
119 if ('' === $internalLogin || null === $internalLogin) {
120 $isNewUser = true;
121 }
122
123 $soapAction = '';
124 $nspref = '';
125 if ($this->use_dot_net) {
126 $soapAction = $this->server_nms . '/isValidSession';
127 $nspref = 'ns1:';
128 }
129
130 $valid = $this->client->call(
131 'isValidSession',
132 [
135 $nspref . 'new_user' => $isNewUser
136 ],
137 $this->server_nms,
138 $soapAction
139 );
140
142 $valid = [
'valid' =>
false];
143 }
144
145 if (
$valid[
'valid'] !==
true) {
147 }
148
150 $status->setReason(
'err_wrong_login');
151 return false;
152 }
153
154 if (!$isNewUser) {
156 return true;
157 }
158
159 if (!$this->
settings->get(
'soap_auth_create_users')) {
160
162 return false;
163 }
164
167
168 $usrData = [];
169 $usrData[
'firstname'] =
$valid[
'firstname'];
170 $usrData[
'lastname'] =
$valid[
'lastname'];
171 $usrData[
'email'] =
$valid[
'email'];
172 $usrData['login'] = $internalLogin;
173 $usrData['passwd'] = '';
175
176 $password = '';
177 if ($this->
settings->get(
'soap_auth_allow_local')) {
179 $password = $passwords[0];
180 $usrData['passwd'] = $password;
182 }
183
184 $usrData['auth_mode'] = 'soap';
186 $usrData['profile_incomplete'] = 1;
187
188 $userObj->assignData($usrData);
189 $userObj->setTitle($userObj->getFullname());
190 $userObj->setDescription($userObj->getEmail());
191 $userObj->setLanguage($this->
language->getDefaultLanguage());
192
194 $userObj->setTimeLimitUnlimited(true);
195 $userObj->setTimeLimitFrom(time());
196 $userObj->setTimeLimitUntil(time());
197 $userObj->setOwner(0);
198 $userObj->create();
199 $userObj->setActive(true);
200 $userObj->updateOwner();
201 $userObj->saveAsNew();
202 $userObj->writePrefs();
203
204 $this->rbacAdmin->assignUser(
205 (
int) $this->
settings->get(
'soap_auth_user_default_role',
'4'),
206 $userObj->getId()
207 );
208
209 if ($this->
settings->get(
'soap_auth_account_mail',
'0')) {
211 $registrationSettings->setPasswordGenerationStatus(true);
212
214 $registrationSettings,
217 );
218 $accountMail
219 ->withDirectRegistrationMode()
220 ->send($userObj, $password, false);
221 }
222
223 $status->setAuthenticatedUserId($userObj->getId());
224 return true;
225 }
Class ilAccountRegistrationMail.
setTranslatedReason(string $a_reason)
Set translated reason.
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
static _lookupId($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.