From TonyM, 2 Years ago, written in Plain Text.
Embed
  1. #!/usr/bin/php
  2. <?php
  3.  
  4. if (isset($argv[1]) && $argv[1] == '-d') {
  5.     $debug = true;
  6.     $config['auth_ad_debug'] = 1;
  7. }
  8.  
  9. $init_modules = array('web');
  10. require __DIR__ . '/includes/init.php';
  11.  
  12.  
  13. // if ldap like, check selinux
  14. if($config['auth_mechanism'] = 'ldap' || $config['auth_mechanism'] = "active_directory" ) {
  15.     $output = shell_exec('getsebool httpd_can_connect_ldap');
  16.     if ($output != "httpd_can_connect_ldap --> on\n") {
  17.         print_error("You need to run: setsebool -P httpd_can_connect_ldap=1");
  18.         exit;
  19.     }
  20. }
  21.  
  22. $username = readline('Username: ');
  23. echo 'Password: ';
  24. `stty -echo`;
  25. $password = trim(fgets(STDIN));
  26. `stty echo`;
  27. echo PHP_EOL;
  28.  
  29. echo "Authenticate user $username: \n";
  30. if (authenticate($username, $password)) {
  31.     print_message("AUTH SUCCESS\n");
  32. } else {
  33.     print_error("AUTH FAILURE\n");
  34. }
  35.  
  36. echo 'ID: ' . get_userid($username) . PHP_EOL;
  37. echo 'Name: ' . get_fullname($username) . PHP_EOL;
  38. echo 'Level: ' . get_userlevel($username) . PHP_EOL;
  39. echo 'Groups: ' . implode('; ', get_group_list()) . PHP_EOL;
  40.  
  41. unset($password);
  42.