Download the PHP package commifreak/yii2-ldap-auth without Composer
On this page you can find all versions of the php package commifreak/yii2-ldap-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download commifreak/yii2-ldap-auth
More information about commifreak/yii2-ldap-auth
Files in commifreak/yii2-ldap-auth
Package yii2-ldap-auth
Short Description Another Yii2 LDAP Auth Extension
License BSD-3-Clause
Informations about the package yii2-ldap-auth
yii2-ldap-auth
This extensions adds a simple LDAP-Auth mechanism for your yii2 application
What it does
- Tries to bind to selected domain with username/credential entered in LoginForm
- Read user data attributes after successful bind to retrieve sid and other values
Features
- User login via LDAP
- Read self defined LDAP attributes
- Domain autodetection based on IPFilter.
- Filter out results by checking every results
sidHistory
- Optional query caching
Installation
Preferred way to install, is through composer:
Setup
Either you use it as standalone or add this as component:
You can omit autodetectIps
if you don't want Ips for a specific domain.
You can set useSSL
if you want to use encryption.
Attention! You need to define baseDn
. This defines the baseDN in where the function will search for the user data!
Usage
There are 5 basic functions:
autoDetect($overrideIp)
- Tries to detect the User's client IP (with Proxy support) and determines the Domain to use
login($username, $password, $domainKey, $fetchUserDN)
- Tries to connect to domain and bind to it as
$username
with$password
$domainKey
defines the domain to use (either detected byautoDetect
or by passing the key number of the configuration array)- If you set it to
false
or pass nothing, the login function loops through every domain and tries to log you in ( default). $fetchUserDN
determines the user DN, in case you want a bind via a users DN instead of username@hostname
- Tries to connect to domain and bind to it as
fetchUserData($attributes)
- Queries the LDAP for the logged in user and gets some attributes (adjustable list of attributes)
searchUser($searchFor, $attributes, $searchFilter, $domainKey, $onlyActiveAccounts, $allDomainsHaveToBeReachable)
- Searches for a user in the LDAP-Directory. This requires a search-user which is configured in the component options.
- The options let you define what attributes you want back and in which you are searching (defaults to lastname, firstname, username and class=person).
$domainKey
lets you set a fixed domain (from autoDetect as example) to search. Otherwise, it searches in every domain$onlyActiveAccounts
lets you decide whether you only want active or all accounts to be returned. defaults to false!$allDomainsHaveToBeReachable
True: All configured domains need to be reachable in order to get a result. If one is not reachable, false will be returned
updateAttributes
lets you update the user attributes$attributes
The attribute (array keys are the attribute names, the array values are the attribute values)$dn
The DN which should be updated - if not provided, the eventually previous examined one will be used.
Example
View
I've added a new attribute to LoginForm location
which holds the domain-key.
To use the autoDetect feature, you have now nothing else to do! The plugin takes care of it automatically! You just want to set the location dropdown to 0, by setting the following inside your LoginForm:
Login
This is based on the default LoginForm->login() function
This also tries to sync user's data with the LDAP.
User attribute update
The database
I've added/changed the user table as follow, to add a sid, firstname, lastname and phone column: