{"id":22788534,"url":"https://github.com/ldaptools/ldaptools","last_synced_at":"2025-05-16T11:06:14.930Z","repository":{"id":26644970,"uuid":"30100981","full_name":"ldaptools/ldaptools","owner":"ldaptools","description":"LdapTools is a feature-rich LDAP library for PHP 5.6+.","archived":false,"fork":false,"pushed_at":"2023-03-30T16:14:12.000Z","size":1690,"stargazers_count":203,"open_issues_count":29,"forks_count":44,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-12T08:18:46.512Z","etag":null,"topics":["active-directory","exchange","ldap","php-ldap"],"latest_commit_sha":null,"homepage":"http://www.phpldaptools.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldaptools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-01-31T03:33:10.000Z","updated_at":"2024-07-20T01:38:42.000Z","dependencies_parsed_at":"2022-08-21T14:50:35.162Z","dependency_job_id":"35f9b53d-7acb-431e-b0c4-011eb417ed76","html_url":"https://github.com/ldaptools/ldaptools","commit_stats":{"total_commits":823,"total_committers":5,"mean_commits":164.6,"dds":0.09356014580801941,"last_synced_commit":"b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldaptools%2Fldaptools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldaptools%2Fldaptools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldaptools%2Fldaptools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldaptools%2Fldaptools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldaptools","download_url":"https://codeload.github.com/ldaptools/ldaptools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518383,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-directory","exchange","ldap","php-ldap"],"created_at":"2024-12-12T01:32:22.536Z","updated_at":"2025-05-16T11:06:09.914Z","avatar_url":"https://github.com/ldaptools.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LdapTools [![Build Status](https://travis-ci.org/ldaptools/ldaptools.svg)](https://travis-ci.org/ldaptools/ldaptools) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/ldaptools/ldaptools?branch=master\u0026svg=true)](https://ci.appveyor.com/project/ChadSikorra/ldaptools) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ldaptools/ldaptools/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ldaptools/ldaptools/?branch=master) [![Latest Stable Version](https://poser.pugx.org/ldaptools/ldaptools/v/stable.svg)](https://packagist.org/packages/ldaptools/ldaptools)\n-----------\n\nLdapTools is a feature-rich LDAP library for PHP 5.6+. It was designed to be customizable for use with pretty much any \ndirectory service, but contains default attribute converters and schemas for Active Directory and OpenLDAP. \n \n * A fluent and easy to understand syntax for [generating LDAP queries](#searching-ldap).\n * Easily [create](#creating-ldap-objects)/[modify](#modifying-ldap-objects)/[delete](#deleting-ldap-objects)/[restore](/docs/en/tutorials/Using-the-LDAP-Manager.md#restoring-ldap-objects) common LDAP objects (Users, Groups, Contacts, Computers, OUs).\n * Retrieve LDAP objects as either a simple array or an object with automagic setters/getters.\n * A [logging mechanism](/docs/en/reference/Logging.md) for all LDAP operations\n * An [event system](/docs/en/reference/Events.md) for further customization, extensibility, and integration.\n * Parse and create [LDIF files](/docs/en/tutorials/LDIF-Files.md).\n * View and modify [Active Directory permissions](/docs/en/tutorials/AD-Permissions.md).\n\n### Installation\n\nThe recommended way to install LdapTools is using [Composer](http://getcomposer.org/download/):\n\n```bash\ncomposer require ldaptools/ldaptools\n```\n\n### Getting Started\n\nThe easiest way to get started is by creating a YAML config file. See the [example config](resources/config/example.yml) file for basic usage. See the \n[configuration file reference doc](/docs/en/reference/Main-Configuration.md) for a list of all available options.\n\nOnce you have a configuration file defined, you can get up and running by doing the following:\n\n```php\nuse LdapTools\\Configuration;\nuse LdapTools\\LdapManager;\n\n$config = (new Configuration())-\u003eload('/path/to/ldap/config.yml');\n$ldap = new LdapManager($config);\n```\n\n### Searching LDAP\n\nWith the `LdapManager` up and going you can now easily build LDAP queries without having to remember all the special \nsyntax for LDAP filters. All values are also automatically escaped. Check the [tutorial](/docs/en/tutorials/Building-LDAP-Queries.md) for all\navailable methods and the [cookbook](/docs/en/cookbook/Common-LDAP-Queries.md) for more query examples.\n\n```php\nuse LdapTools\\Object\\LdapObjectType;\n\n// Get an instance of the query...\n$query = $ldap-\u003ebuildLdapQuery();\n\n// Returns a LdapObjectCollection of all users whose first name \n// starts with 'Foo' and last name is 'Bar' or 'Smith'.\n// The result set will also be ordered by state name (ascending).\n$users = $query-\u003efromUsers()\n    -\u003ewhere($query-\u003efilter()-\u003estartsWith('firstName', 'Foo'))\n    -\u003eorWhere(['lastName' =\u003e 'Bar'])\n    -\u003eorWhere(['lastName' =\u003e 'Smith'])\n    -\u003eorderBy('state')\n    -\u003egetLdapQuery()\n    -\u003egetResult();\n\necho \"Found \".$users-\u003ecount().\" user(s).\";\nforeach ($users as $user) {\n    echo \"User: \".$user-\u003egetUsername();\n}\n\n// Get all OUs and Containers at the base of the domain, ordered by name.\n$results = $ldap-\u003ebuildLdapQuery()\n    -\u003efrom(LdapObjectType::OU)\n    -\u003efrom(LdapObjectType::CONTAINER)\n    -\u003eorderBy('name')\n    -\u003esetScopeOneLevel()\n    -\u003egetLdapQuery()\n    -\u003egetResult();\n\n// Get a single LDAP object and select some specific attributes...\n$user = $ldap-\u003ebuildLdapQuery()\n    -\u003eselect(['upn', 'guid', 'sid', 'passwordLastSet'])\n    -\u003efromUsers()\n    -\u003ewhere(['username' =\u003e 'chad'])\n    -\u003egetLdapQuery()\n    -\u003egetSingleResult();\n\n// Get a single attribute value from a LDAP object...\n$guid = $ldap-\u003ebuildLdapQuery()\n    -\u003eselect('guid')\n    -\u003efromUsers()\n    -\u003ewhere(['username' =\u003e 'chad'])\n    -\u003egetLdapQuery()\n    -\u003egetSingleScalarResult();\n    \n// It also supports the concepts of repositories...\n$userRepository = $ldap-\u003egetRepository('user');\n\n// Find all users whose last name equals Smith.\n$users = $userRepository-\u003efindByLastName('Smith');\n\n// Get the first user whose username equals 'jsmith'. Returns a `LdapObject`.\n$user = $userRepository-\u003efindOneByUsername('jsmith');\necho \"First name \".$user-\u003egetFirstName().\" and last name \".$user-\u003egetLastName();\n```\n\nSee [the docs](/docs/en/tutorials/Building-LDAP-Queries.md) for more information on building LDAP queries.\n\n### Modifying LDAP Objects\n\nModifying LDAP is as easy as searching for the LDAP object as described above, then making changes directly to the object\nand saving it back to LDAP using the `LdapManager`.\n\n```php\n$user = $ldap-\u003ebuildLdapQuery()\n    -\u003eselect(['title', 'mobilePhone', 'disabled'])\n    -\u003efromUsers()\n    -\u003ewhere(['username' =\u003e 'jsmith'])\n    -\u003egetLdapQuery()\n    -\u003egetSingleResult();\n\n// Make some modifications to the user account.\n// All these changes are tracked so it knows how to modify the object.\n$user-\u003esetTitle('CEO');\n\nif ($user-\u003ehasMobilePhone()) {\n    $user-\u003eresetMobilePhone();\n}\n\n// Set a field by a property instead...\nif ($user-\u003edisabled) {\n    $user-\u003edisabled = false;\n}\n\n// Add a value to an attribute...\n$user-\u003eaddOtherIpPhones('#001-5555');\n// Add a few values at one time...\n$user-\u003eaddOtherIpPhones('#001-4444', '#001-3333', '#001-2222');\n\n// Now actually save the changes back to LDAP...\ntry {\n    $ldap-\u003epersist($user);\n} catch (\\Exception $e) {\n    echo \"Error updating user! \".$e-\u003egetMessage();\n}\n```\n\nSee [the docs](/docs/en/tutorials/Modifying-LDAP-Objects.md) for more information on modifying LDAP objects.\n\n### Deleting LDAP Objects\n\nDeleting LDAP objects is a simple matter of searching for the object you want to remove, then passing it to the delete\nmethod on the `LdapManager`:\n\n```php\n// Decide they no longer work here and should be deleted?\n$user = $userRepository-\u003efindOneByUsername('jsmith');\n\ntry {\n    $ldap-\u003edelete($user);\n} catch (\\Exception $e) {\n    echo \"Error deleting user! \".$e-\u003egetMessage();\n}\n```\n\n### Creating LDAP Objects\n \nCreating LDAP objects is easily performed by just passing what you want the attributes to be and what container/OU the\nobject should end up in:\n\n```php\n$ldapObject = $ldap-\u003ecreateLdapObject();\n\n// Creating a user account (enabled by default)\n$ldapObject-\u003ecreateUser()\n    -\u003ein('cn=Users,dc=example,dc=local')\n    -\u003ewith(['username' =\u003e 'jsmith', 'password' =\u003e '12345'])\n    -\u003eexecute();\n\n// Create a typical AD global security group...\n$ldapObject-\u003ecreateGroup()\n    -\u003ein('dc=example,dc=local')\n    -\u003ewith(['name' =\u003e 'Generic Security Group'])\n    -\u003eexecute();\n\n// Creates a contact user...\n$ldapObject-\u003ecreateContact()\n    -\u003ein('dc=example,dc=local')\n    -\u003ewith(['name' =\u003e 'Some Guy', 'emailAddress' =\u003e 'SomeGuy@SomeDomain.com'])\n    -\u003eexecute();\n\n// Creates a computer object...\n$ldapObject-\u003ecreateComputer()\n    -\u003ein('dc=example,dc=local')\n    -\u003ewith(['name' =\u003e 'MYWOKRSTATION'])\n    -\u003eexecute();\n    \n// Creates an OU object...\n$ldapObject-\u003ecreateOU()\n    -\u003ein('dc=example,dc=local')\n    -\u003ewith(['name' =\u003e 'Employees'])\n    -\u003eexecute();\n```\n\nSee [the docs](/docs/en/tutorials/Creating-LDAP-Objects.md) for more information on creating LDAP objects.\n\n### Documentation\n\nBrowse [the docs folder](/docs/en) for more information about LdapTools.\n\n* [Main Configuration Reference](/docs/en/reference/Main-Configuration.md)\n* [Schema Configuration](/docs/en/reference/Schema-Configuration.md)\n* [Using the LdapManager](/docs/en/tutorials/Using-the-LDAP-Manager.md)\n* [Building LDAP Queries](/docs/en/tutorials/Building-LDAP-Queries.md)\n* [Creating LDAP Objects](/docs/en/tutorials/Creating-LDAP-Objects.md)\n* [Modifying LDAP Objects](/docs/en/tutorials/Modifying-LDAP-Objects.md)\n* [LDIF files](/docs/en/tutorials/LDIF-Files.md)\n* [Active Directory Permissions](/docs/en/tutorials/AD-Permissions.md)\n* [Creating Exchange Mailboxes](/docs/en/cookbook/Creating-Exchange-Mailboxes.md)\n* [Default Schema Attributes](/docs/en/reference/Default-Schema-Attributes.md)\n* [The Event System](/docs/en/reference/Events.md)\n\n### TODO\n\nThings that still need to be implemented:\n\n* Automatic generation of the schema based off of information in LDAP.\n* More work needed on the OpenLDAP schema.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldaptools%2Fldaptools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldaptools%2Fldaptools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldaptools%2Fldaptools/lists"}