Download the PHP package rgergo67/openldap without Composer

On this page you can find all versions of the php package rgergo67/openldap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openldap

Don't use this for production

Feel free to fork it and modify it as you wish, but don't use this for production. The version numbering does not follow any conventions, this exists only for test purposes.

Openldap-laravel

With this package you can add users to OpenLdap, edit and delete them, manage their attributes and add them to posix groups. The package is used to a specific project with specific needs, feel free to modify it.

Install

Install using composer:

Run php artisan vendor:publish this will copy openldap.php config file to config directory. Add the following line to the config/app.php providers array:

Basic usage

To be able to use this package, your User model needs to have two things.

DN attribute

First it has to have a dn attribute, which you can create virtually or get from a mysql field. In our User.php model it looks like this:

We store employees and students in different organization units, therefor we need to be able to decide which one the given user is. (Students have a 6 char length uid, employees have 10 char length uid). An example value for this dn attribute is cn=rgergo6,ou=student,ou=people,dc=example,dc=com

ldap-format attribute

Second thing is an array called ldap-attribute. This array translates mysql fields to ldap fields. For example:

If you do an addUser($user); the package will use this array to create a user in ldap.

Object class

The objectClass attribute tells for ldap what kind of object the user is (which will specify what kind of attributes you can give it). You can edit this value in the config file, we use this:

In most cases the top, person, posixAccount, InetorgPerson is enough, but we need the others too for our project.

Configuration

In the config file you can see admin_dn and admin_password these are used to connect to openldap, and should be defined in your .env file.

dn

There are 4 other dn keys in config: base_user_dn: if you have multiple user subtrees like we do (students, employees), then these should go below a ou=people node, so if you are looking for a user with [email protected] you don't have to filter twice (once in student tree, once in employee tree). base_student_dn and base_employee_dn: we need to know where these are, so when we create a new employee, we can put it to the right place bsae_group_dn: the node where your groups are.

Groups

We use posix groups. The base_group_dn is ou=sys,dc=example,dc=com but you can use anything. Below this node is a ou=joomla and a ou=moodle for grouping the similar systems together. If we create a new joomla site like hr.example.com, we create a new organization unit for it ou=hr.example.com,ou=joomla,ou=sys,dc=example,dc=com, and a posix group below it for every joomla group (editor, registered, administrator): cn=editor,ou=hr.example.com,ou=joomla,ou=sys,dc=example,dc=com

Usage

Updating user

If you would like to update a user, first check if its uid (or the attribute that is part of the dn) is dirty (is changed). If so, first rename it, and update afterwards. The third parameter of rename should only be used if you move the record somewhere else. Note that second parameter is only RDN, not the full DN.

One more thing: if you rename something, the first parameter should be the old DN. If you for example hook into the users updating event, the $user objects $user->uid field (that is part of the DN) would contain the updated uid (if you modified it). To get the old dn, make use of Laravels $user->getOriginal() function.

Sync groups

Sometimes you just need to be sure the users groups are all synced. This function removes all groups from user, and adds them again.

Sync groups on user save save

Hook into the users saved event, and run group sync there. We have a series of checkboxes with group names that we can retrieve with request('groups').

Cleaning arrays

If you get back the search results from LDAP it has an ugly format, it is hard to work with. If you use the cleanUpEntry($entry) function, it will return a beutified cleaned php array. Credit goes to Chl

Example for simple search result:

If we clean the result:


All versions of openldap with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rgergo67/openldap contains the following files

Loading the files please wait ....