You are here

README.txt in Lightweight Directory Access Protocol (LDAP) 7



=======================================
PHP to Test for Allowed LDAP Users
=======================================

Remember:
-- php module must be enabled (its one of the core drupal modules)
-- code should not be enclosed in <?php   ?>

Two variables are available:

(1) $_name - the username ldap server configuration has mapped user to such as "jdoe" etc.  How this is derived is configured in ldap_servers module.



(2) $_ldap_user_entry - their ldap entry as returned from php ldap extension.

$_ldap_user_entry is something like:

array(
    'dn' => 'cn=jkool,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu',
    'mail' => array( 0 => 'jkool@guests.myuniversity.edu', 'count' => 1),
    'sAMAccountName' => array( 0 => 'jkool', 'count' => 1),
    'memberOf' => array( 0 => 'cn=sysadmins,ou=it,dc=ad,dc=myuniversity,dc=edu', 'count' => 1),
  );


Result should print 1 for allowed or 0 for disallowed.  The function used to evaluate the code is php_eval() in php.module

---------------------------------
Example 1:


//exclude users with guests.myuniversity.edu email address
if (strpos($_ldap_user_entry['attr']['mail'][0], '@guests.myuniversity.edu') === FALSE) {
  print 1;
}
else {
  print 0;
}

---------------------------------
Example 2:

// test behaviour of nobody excluded
print 1;

---------------------------------
Example 3:

// test behaviour of nobody excluded
print 0;







File

ldap_authentication/README.txt
View source
  1. =======================================
  2. PHP to Test for Allowed LDAP Users
  3. =======================================
  4. Remember:
  5. -- php module must be enabled (its one of the core drupal modules)
  6. -- code should not be enclosed in
  7. Two variables are available:
  8. (1) $_name - the username ldap server configuration has mapped user to such as "jdoe" etc. How this is derived is configured in ldap_servers module.
  9. (2) $_ldap_user_entry - their ldap entry as returned from php ldap extension.
  10. $_ldap_user_entry is something like:
  11. array(
  12. 'dn' => 'cn=jkool,ou=guest accounts,dc=ad,dc=myuniversity,dc=edu',
  13. 'mail' => array( 0 => 'jkool@guests.myuniversity.edu', 'count' => 1),
  14. 'sAMAccountName' => array( 0 => 'jkool', 'count' => 1),
  15. 'memberOf' => array( 0 => 'cn=sysadmins,ou=it,dc=ad,dc=myuniversity,dc=edu', 'count' => 1),
  16. );
  17. Result should print 1 for allowed or 0 for disallowed. The function used to evaluate the code is php_eval() in php.module
  18. ---------------------------------
  19. Example 1:
  20. //exclude users with guests.myuniversity.edu email address
  21. if (strpos($_ldap_user_entry['attr']['mail'][0], '@guests.myuniversity.edu') === FALSE) {
  22. print 1;
  23. }
  24. else {
  25. print 0;
  26. }
  27. ---------------------------------
  28. Example 2:
  29. // test behaviour of nobody excluded
  30. print 1;
  31. ---------------------------------
  32. Example 3:
  33. // test behaviour of nobody excluded
  34. print 0;