You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_webdavauth.php 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 deleteUser($uid) {
  28. // Can't delete user
  29. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to delete users from web frontend using WebDAV user backend', 3);
  30. return false;
  31. }
  32. public function setPassword ( $uid, $password ) {
  33. // We can't change user password
  34. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to change password for users from web frontend using WebDAV user backend', 3);
  35. return false;
  36. }
  37. public function checkPassword( $uid, $password ) {
  38. $arr = explode('://', $this->webdavauth_url, 2);
  39. if( ! isset($arr) OR count($arr) !== 2) {
  40. OC_Log::write('OC_USER_WEBDAVAUTH', 'Invalid Url: "'.$this->webdavauth_url.'" ', 3);
  41. return false;
  42. }
  43. list($webdavauth_protocol, $webdavauth_url_path) = $arr;
  44. $url= $webdavauth_protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$webdavauth_url_path;
  45. $headers = get_headers($url);
  46. if($headers==false) {
  47. OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "'.$webdavauth_protocol.'://'.$webdavauth_url_path.'" ', 3);
  48. return false;
  49. }
  50. $returncode= substr($headers[0], 9, 3);
  51. if(substr($returncode, 0, 1) === '2') {
  52. return $uid;
  53. } else {
  54. return false;
  55. }
  56. }
  57. /*
  58. * we don´t know if a user exists without the password. so we have to return true all the time
  59. */
  60. public function userExists( $uid ){
  61. return true;
  62. }
  63. /**
  64. * @return bool
  65. */
  66. public function hasUserListings() {
  67. return false;
  68. }
  69. /*
  70. * we don´t know the users so all we can do it return an empty array here
  71. */
  72. public function getUsers($search = '', $limit = 10, $offset = 0) {
  73. $returnArray = array();
  74. return $returnArray;
  75. }
  76. }