From a3e648d288f1fd561c5703804b55d0af97d4c0a5 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Fri, 12 Jul 2024 12:03:10 +0200 Subject: [PATCH] update docs --- docs/20_Usage.md | 26 +++++++++------------- docs/30_Methods.md | 2 +- docs/40_Configuration.md | 48 +++++++++++++++++++++++++++++++++------- docs/50_Examples.md | 11 +++------ 4 files changed, 54 insertions(+), 33 deletions(-) diff --git a/docs/20_Usage.md b/docs/20_Usage.md index 5bd6932..0bd76be 100644 --- a/docs/20_Usage.md +++ b/docs/20_Usage.md @@ -10,24 +10,18 @@ require_once '[APPROOT]/classes/ldap.class.php'; As an example I create a hash named $aConfig and save it as "inc_config.php". + ```php return [ - ... - - 'ldap-master' => [ - 'server' => 'ldaps://ldap.example.com', - 'DnLdapUser' => 'cn=Lookup,ou=Service,dc=some,dc=example.com', - 'PwLdapUser' => 'PasswordOfLookupUser', - - // node where to find users that are allowed to login - 'DnUserNode' => 'ou=People,dc=some,dc=example.com', - - // node where to find my app - 'DnAppNode' => 'cn=MyApp,dc=some,dc=example.com', - 'debugLevel' => 0, - ], - ... - + ... + 'ldap-master' => [ + 'server' => 'ldaps://ldap.example.com', + 'DnLdapUser' => 'cn=Lookup,ou=Service,dc=some,dc=example.com', + 'PwLdapUser' => 'PasswordOfLookupUser', + + // See Configuration page for all values. + ], + ... ]; ``` diff --git a/docs/30_Methods.md b/docs/30_Methods.md index 86962bd..a4cdcd0 100644 --- a/docs/30_Methods.md +++ b/docs/30_Methods.md @@ -83,7 +83,7 @@ set a ldap config 'server' => 'ldaps://ldap.example.com', 'port' => 636, 'DnLdapUser' => 'cn=Lookup,ou=ServiceAccounts,dc=org,dc=example.com', // ldap rdn oder dn - 'PwLdapUser' => 'IkHEFFzlZ...99j0h8WdI0LrLhxU', // password + 'PwLdapUser' => 'PasswordOfLookupUser', // password 'DnUserNode' => 'ou=People,ou=ORG,dc=org,dc=example.com', 'DnAppNode' => '' optional dn ... if a user must be member of a given group 'protoVersion' => 3 diff --git a/docs/40_Configuration.md b/docs/40_Configuration.md index 170c2b6..7964db1 100644 --- a/docs/40_Configuration.md +++ b/docs/40_Configuration.md @@ -2,11 +2,43 @@ When initializing a new imlldap object or use setConfig then you can apply these values: -Var | Type | Desciption | Example --- |-- |-- |-- -'server' | string | Server connection with "ldap(s)://host[:port]" | 'ldaps://ldap.example.com' -'DnLdapUser' | string | Bind user as ldap rdn or dn | 'cn=Lookup,ou=ServiceAccounts,dc=org,dc=example.com' -'PwLdapUser' | string | password for bind user | -'DnUserNode' | string | for user metods: set a DN where users are | 'ou=People,ou=ORG,dc=org,dc=example.com' -'protoVersion' | integer | ldap protocol version | 3 -'debugLevel' | integer | Value for LDAP_OPT_DEBUG_LEVEL | 7 +Var | Type | Desciption | Example +-- |-- |-- |-- +`server` | string | Server connection with "ldap(s)://host[:port]" | 'ldaps://ldap.example.com' +`DnLdapUser` | string | Bind user as ldap rdn or dn | 'cn=Lookup,ou=ServiceAccounts,dc=org,dc=example.com' +`PwLdapUser` | string | password for bind user | 'PasswordOfLookupUser' +`DnUserNode` | string | for user metods: set a DN where users are | 'ou=People,ou=ORG,dc=org,dc=example.com' +`protoVersion` | integer | ldap protocol version | 3 +`debugLevel` | integer | Value for LDAP_OPT_DEBUG_LEVEL when using debugOn() | 7 + +### Example: + +As an example I create a hash named $aConfig and save it as "inc_config.php". + +```php +return [ + ... + 'ldap-master' => [ + 'server' => 'ldaps://ldap.example.com', + 'DnLdapUser' => 'cn=Lookup,ou=Service,dc=some,dc=example.com', + 'PwLdapUser' => 'PasswordOfLookupUser', + 'DnUserNode' => 'ou=People,dc=some,dc=example.com', + 'debugLevel' => 0, + ], + ... +]; +``` + +```php +$aConfig = require_once('inc_config.php'); +require_once '[APPROOT]/classes/ldap.class.php'; + +$oLdap=new imlldap($aConfig['ldap-maser']); + +// ... + +// update a single config item +$oLdap->setConfig([ + 'debugLevel' => 3, +]); +``` diff --git a/docs/50_Examples.md b/docs/50_Examples.md index 8efad52..c657809 100644 --- a/docs/50_Examples.md +++ b/docs/50_Examples.md @@ -10,7 +10,7 @@ $aUser = $oLdap->getUserInfo("john@example.com", ["memberof", "uid"]); print_r($oLdap->normalizeSearchentry($aUser)); ``` -### Verify user and password for login +## Verify user and password for login ```php // set values from $_FORM or $_POST data of your login form here @@ -32,18 +32,13 @@ $oLdap->close(); ## Debugging If you want to find connection problems then use debugOn(). -This enables the echoing of ldap actions for connect, bind and more. - - +This enables the echoing of ldap actions for connect, bind and class internal debug messages. ```php - -// this will set LDAP_OPT_DEBUG_LEVEL -$aConfig['debugLevel']=7; - $oLdap = new imlldap($aConfig); // enable showing debug output +// This method sets LDAP_OPT_DEBUG_LEVEL to $aConfig['debugLevel']; $oLdap->debugOn(); // then do something ... the first action will conect and bind -- GitLab