diff --git a/docs/USAGE_WITH_USER_MODEL.md b/docs/USAGE_WITH_USER_MODEL.md index 0db5a4d..b2c77a6 100644 --- a/docs/USAGE_WITH_USER_MODEL.md +++ b/docs/USAGE_WITH_USER_MODEL.md @@ -49,7 +49,7 @@ yii migrate --migrationPath=@Edvlerblog/Adldap2/migrations ### 5. Change the identity class in your web.conf (basic template) / main.conf (advanced template). ```php 'components' => [ - //... + //user entry already exists! 'user' => [ 'identityClass' => 'Edvlerblog\Adldap2\model\UserDbLdap', //... @@ -58,6 +58,7 @@ yii migrate --migrationPath=@Edvlerblog/Adldap2/migrations ``` ### 6. In the basic template change the models/LoginForm.php to use the new identity class. +**Version 1 with sAMAccountname attribute (login eg. mmaderer)** ```php //... public function getUser() @@ -71,6 +72,21 @@ public function getUser() //... ``` +**Version 2 with another attribute (login eg. mmaderer@test.lan)** +```php +//... +public function getUser() +{ + if ($this->_user === false) { + $this->_user = \Edvlerblog\Adldap2\model\UserDbLdap::findByAttribute('userPrincipalName',$this->username); //With Principal Name + //$this->_user =\Edvlerblog\Adldap2\model\UserDbLdap::findByAttribute('mail',$this->username); //With Mail + } + + return $this->_user; +} +//... +``` + ### 7. Add the LdapController to the controllerMap in the config/console.conf (basic template) OR console/config/main.conf (advanced template). Maybe the 'controllerMap' section is commented out. ```php @@ -151,7 +167,7 @@ Maybe you think: Configuration, what?? But there are severel possible ways to co **role** = This term is used for a role in yii2. If you don't know what a role is look at http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac **group** = This term is used for a group in Active Directory. **user** = Means a user which exists in Active Directory. -**username or login** = sAMAccountName attribute in Active Directory (the username you type at the windows login) +**username or login** = Depending on Task 1 Number 6 the attribute you used for login. **assigned group** = Means that a user is member of a group in Active Directory **assigned role** = Means that a user is member of a role in yii2 diff --git a/readme.md b/readme.md index b43b3f1..7fa51fe 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,30 @@ or add ``` to the require section of your composer.json +## Functions of the Plugin! +It has been a long way since 29. Jan 2014, many functions has been added. I noticed for myself that a short overview might help everyone to see whats possible. + +**The simple [Method 1](#usage-method-1-simple-usage-without-a-user-model)** +* Query only informations from Active Directory. + + +**The deep integration with [Method 2](#usage-method-2-deep-integration-into-the-yii2-framework-with-a-user-model)** +* Sign in with a Active Directory User is possible **without doing anything in yii2**. The only action needed is creating a Active Directory User and add it to a group in Active Directory. +* Full support of the RBAC-concept from yii2 +* Default is to login with the sAMAccountName [Edvlerblog\Adldap2\model\UserDbLdap.php::findByUsername($username)](src/model/UserDbLdap.php). But using any attribute is possible [Edvlerblog\Adldap2\model\UserDbLdap.php::findByAttribute($attribute,$searchVAlue)](src/model/UserDbLdap.php). +* Default is, that on login the Active Directory Account Status and the group assignments are checked. Based on the results the login is possible or not. +* You can access every Active Directory attribute of the user. [Method 2](#Usage method 2: Deep integration into the yii2 framework with a user model) +* This yii2-extension is highly configurable. + +**How to start??** +* My suggestion is that you should start with Method 1. Start with a configration as described below and do some simple querys. If you see how it works, you can try Method 2. + +**If you have some questions...** +* Please see the the separeted howto's for each Method. +* [Method 1: docs/USAGE_WITHOUT_USER_MODEL.md](docs/USAGE_WITHOUT_USER_MODEL.md) +* [Method 2: docs/USAGE_WITH_USER_MODEL.md](docs/USAGE_WITH_USER_MODEL.md) +* You can try to contanct me! If I find time, I would answer your questions! + ## Configuration @@ -143,9 +167,9 @@ https://github.com/Adldap2/Adldap2/blob/master/docs/configuration.md ### Usage method 1: Simple usage without a user model If you are need to query some informations for a user from the Active Directory this would be best way. -No additional configuration is needed and the only thing to do is to add the configuration as described above to your components section. +No additional configuration is needed and the only thing to do is to add the [configuration](#configuration) as described above to your components section. -You only call the the component as usual. +You only use the extension in the regular Yii2 style: ```php //... $un = 'testuser';