Source for file LDAPAuthNTokens.class.php

Documentation is available at LDAPAuthNTokens.class.php

  1. <?php
  2. /**
  3. * @package harmoni.osid_v2.agentmanagement.authn_methods
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: LDAPAuthNTokens.class.php,v 1.10 2007/09/04 20:25:37 adamfranco Exp $
  9. */
  10.  
  11. require_once(dirname(__FILE__)."/UsernamePasswordAuthNTokens.class.php");
  12.  
  13. /**
  14. * This UserNamePasswordAuthNTokens class encrypts the password passed to it using
  15. * the database's PHP's crypt() function.
  16. *
  17. * @package harmoni.osid_v2.agentmanagement.authn_methods
  18. *
  19. * @copyright Copyright &copy; 2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: LDAPAuthNTokens.class.php,v 1.10 2007/09/04 20:25:37 adamfranco Exp $
  23. */
  24. class LDAPAuthNTokens
  25. extends UsernamePasswordAuthNTokens
  26. {
  27. /**
  28. * Constructor, Adds some additional functionality to that of the parent's
  29. * constructor
  30. *
  31. * @param object Properties $configuration
  32. * @return object
  33. * @access public
  34. * @since 3/4/05
  35. */
  36. function LDAPAuthNTokens ( $configuration ) {
  37. $par = get_parent_class($this);
  38. parent::$par($configuration);
  39. $this->_connector =$configuration->getProperty('connector');
  40. // Validate the configuration options we use:
  41. ArgumentValidator::validate (
  42. $this->_configuration->getProperty('login_fields'),
  43. ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
  44. }
  45.  
  46. /**
  47. * Initialize this object for a set of authentication tokens. The identifier
  48. * is the user's CN, but they may have passed a username or email as part
  49. * of their tokens instead.
  50. *
  51. * @param mixed $tokens
  52. * @return void
  53. * @access public
  54. * @since 3/1/05
  55. */
  56. function initializeForTokens ( $tokens ) {
  57. ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
  58. ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
  59. ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
  60. $this->_tokens = $tokens;
  61. $this->_tokens['password'] = $tokens['password'];
  62. // See if we were passed a system name instead of a full DN as this
  63. // is probably the case. First try the 'main system name' in case
  64. // a broader search returns more results.
  65. $primaryLoginFields = $this->_configuration->getProperty('login_fields');
  66. foreach($primaryLoginFields as $loginField) {
  67. $dns = $this->_connector->getUserDNsBySearch($loginField."=".$tokens['username']);
  68. // printpre($loginField."=".$tokens['username']);
  69. if (count($dns) == 1) {
  70. $this->_identifier = $dns[0];
  71. $this->_tokens['username'] = $dns[0];
  72. return;
  73. }
  74. }
  75. // If we haven't found it, just leave it alone as it might be the DN
  76. // itself.
  77. $this->_identifier = $tokens['username'];
  78. }
  79. }
  80.  
  81. ?>

Documentation generated on Wed, 19 Sep 2007 10:24:50 -0400 by phpDocumentor 1.3.0RC3