Home > Article > Backend Development > How to obtain LDAP server Schema data in PHP
I have been dealing with LDAP recently at work. In the officially recommended client-apis, you can easily find the API corresponding to each language and then interact with the LDAP server. However, when using Apache Directory Studio, this software can actually display Schema data. After carefully reading the official document, I still didn’t see any instructions for querying Schema data (if anyone sees relevant instructions in the document, I hope you can leave a message to let me know) I). But I found the client phpLDAPAdmin written in php, and then through its source code, I discovered how to query Schema data.
Through the official documentation, we found that the Schema data contains the following four parts
syntaxes
attributes
matching_rules
objectclasses
Take querying objectclasses as an example (you can also query it all at once), the corresponding The query method is as follows
The first case
$read_ret = ldap_read($ds, 'cn=Subschema', '(objectClass=subschema)', ['objectclasses']); $read_ret = ldap_read($ds, 'cn=Subschema', '(objectClass=*)', ['objectclasses']);
If the first query cannot be found, use the second one
$read_ret = ldap_read($ds, 'cn=Aggregate,cn=Schema,cn=configuration,dc=example,dc=com', '(objectClass=*)'; $read_ret = ldap_read($ds, 'cn=Schema,cn=configuration,dc=example,dc=com', '(objectClass=*)', ['objectclasses']); $read_ret = ldap_read($ds, 'cn=Schema,ou=Admin,dc=example,dc=com', '(objectClass=*)', ['objectclasses']);
If the second query cannot be found, use The third type
$read_ret = ldap_read($ds, 'cn=schema,cn=config', '(objectClass=*)', ['objectclasses']);
Related recommendations:
Analysis of PHP’s multi-tasking coroutine processing
The above is the detailed content of How to obtain LDAP server Schema data in PHP. For more information, please follow other related articles on the PHP Chinese website!