user_webdavauth.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. class OC_USER_WEBDAVAUTH extends OC_User_Backend {
  23. protected $webdavauth_url;
  24. public function __construct() {
  25. $this->webdavauth_url = OC_Config::getValue( "user_webdavauth_url" );
  26. }
  27. public function createUser() {
  28. // Can't create user
  29. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to create users from web frontend using WebDAV user backend', 3);
  30. return false;
  31. }
  32. public function deleteUser($uid) {
  33. // Can't delete user
  34. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to delete users from web frontend using WebDAV user backend', 3);
  35. return false;
  36. }
  37. public function setPassword ( $uid, $password ) {
  38. // We can't change user password
  39. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to change password for users from web frontend using WebDAV user backend', 3);
  40. return false;
  41. }
  42. public function checkPassword( $uid, $password ) {
  43. $url= 'http://'.urlencode($uid).':'.urlencode($password).'@'.$this->webdavauth_url;
  44. $headers = get_headers($url);
  45. if($headers==false) {
  46. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "'.$this->webdavauth_url.'" ', 3);
  47. return false;
  48. }
  49. $returncode= substr($headers[0], 9, 3);
  50. if(($returncode=='401') or ($returncode=='403')) {
  51. return(false);
  52. }else{
  53. return($uid);
  54. }
  55. }
  56. /*
  57. * we don´t know if a user exists without the password. so we have to return false all the time
  58. */
  59. public function userExists( $uid ){
  60. return true;
  61. }
  62. /*
  63. * we don´t know the users so all we can do it return an empty array here
  64. */
  65. public function getUsers($search = '', $limit = 10, $offset = 0) {
  66. $returnArray = array();
  67. return $returnArray;
  68. }
  69. }