Using the LDAP Protocol in PHP
Just because you can access a restricted area doesn't mean that you have free reign over its contents. In fact, exactly what you can add, modify, and destroy is based on the furnishable credentials that you present to the directory server when you want to carry out its services. The LDAP protocol supplies the means to do so through functions like ldap_bind() and ldap_unbind(), which will provide a connection with the server once you've supplied the necessary credentials.
Several other php functions are required to communicate with an LDAP server; they are responsible for connecting, setting up configuration parameters, binding to, and closing the server. These are discussed in articles on the ldap_connect(), ldap_set_option(), and ldap_unbind() functions.
Once a connection has been established with the LDAP server, the ldap_get_option function can be used to read all of the values of an entry in the result. The ldap_get_option() function returns all of the attribute values as an array of elements, and you can retrieve individual values by indexing into the array.
Until PHP 7.3, the ldap_get_option() and ldap_set_option() functions did not support an optional parameter known as the LDAP Controls. This allows a value to be sent to the LDAP server with a query, which can tell it how to sort or treat a search result or what to return in a response. Now these php functions support the LDAP_OPT_SERVER_CONTROLS and LDAP_OPT_CLIENT_CONTROLS constants, which enable them to set and retrieve this type of information via the current LDAP session.