Skip to content

Commit 79934b6

Browse files
author
robin.kluth
committed
Docs
1 parent 4480efe commit 79934b6

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ __Attention!__ You need to define `baseDn`. This defines the baseDN in where the
4848

4949
## Usage
5050

51-
There are 4 basic functions:
51+
There are 5 basic functions:
5252

5353
* `autoDetect($overrideIp)`
5454
* Tries to detect the User's client IP (with Proxy support) and determines the Domain to use
@@ -69,6 +69,9 @@ There are 4 basic functions:
6969
domain
7070
* `$onlyActiveAccounts` lets you decide whether you only want active or all accounts to be returned. defaults to
7171
false!
72+
* `updateAttributes` lets you update the user attributes
73+
* `$attributes` The attribute (array keys are the attribute names, the array values are the attribute values)
74+
* `$dn` The DN which should be updated - if not provided, the eventually previous examined one will be used.
7275

7376
## Example
7477

@@ -142,15 +145,41 @@ public function login()
142145

143146
This also tries to sync user's data with the LDAP.
144147

148+
### User attribute update
149+
150+
```php
151+
/** @var LdapAuth $ldap */
152+
$ldap = \Yii::$app->ldap;
153+
154+
if (!$ldap->login(\Yii::$app->user->identity->sid, $this->userPassword, false, true)) {
155+
return false;
156+
}
157+
158+
$updateAttrs = [];
159+
160+
if (!empty($this->phone)) {
161+
$updateAttrs['telephonenumber'] = $this->phone;
162+
}
163+
164+
if (!empty($this->room)) {
165+
$updateAttrs['physicaldeliveryofficename'] = $this->room;
166+
}
167+
168+
if (!$ldap->updateAttributes($updateAttrs)) {
169+
return false;
170+
}
171+
```
172+
145173
## The database
146174

147175
I've added/changed the user table as follow, to add a sid, firstname, lastname and phone column:
148176

149177
```sql
150-
CREATE TABLE `user` (
151-
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
152-
`sid` varchar(255) DEFAULT NULL,
153-
`email` varchar(256) NOT NULL,
178+
CREATE TABLE `user`
179+
(
180+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
181+
`sid` varchar(255) DEFAULT NULL,
182+
`email` varchar(256) NOT NULL,
154183
`firstname` varchar(255) DEFAULT NULL,
155184
`lastname` varchar(255) DEFAULT NULL,
156185
`phone` varchar(255) DEFAULT NULL,

0 commit comments

Comments
 (0)