diff options
author | pmichaud <pmichaud@524c5546-5005-0410-9a3e-e25e191bd360> | 2006-08-15 12:35:22 +0000 |
---|---|---|
committer | pmichaud <pmichaud@524c5546-5005-0410-9a3e-e25e191bd360> | 2006-08-15 12:35:22 +0000 |
commit | 272825447887da7beb60d8284c20195c751462d0 (patch) | |
tree | aacc7975f72610e26ad96e91d99700adcb260711 /scripts/authuser.php | |
parent | a5704b1bf2b3f21bea41338b54d3a849195bc4b1 (diff) | |
download | pmwiki.svn-272825447887da7beb60d8284c20195c751462d0.tar.bz2 |
Update to ldap to allow ldaps://...
git-svn-id: svn://pmwiki.org/pmwiki/trunk@1495 524c5546-5005-0410-9a3e-e25e191bd360
Diffstat (limited to 'scripts/authuser.php')
-rw-r--r-- | scripts/authuser.php | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/scripts/authuser.php b/scripts/authuser.php index 5fc8b23a..9479bf19 100644 --- a/scripts/authuser.php +++ b/scripts/authuser.php @@ -55,7 +55,7 @@ function AuthUserId($pagename, $id, $pw=NULL) { if ($apage && preg_match_all("/^\\s*([@\\w][^\\s:]*):(.*)/m", $apage['text'], $matches, PREG_SET_ORDER)) { foreach($matches as $m) { - if (!preg_match_all('/\\bldap:\\S+|[^\\s,]+/', $m[2], $v)) + if (!preg_match_all('/\\bldaps?:\\S+|[^\\s,]+/', $m[2], $v)) continue; if ($m[1]{0} == '@') foreach($v[0] as $g) $auth[$g][] = $m[1]; @@ -107,16 +107,15 @@ function AuthUserLDAP($pagename, $id, $pw, $pwlist) { if (!$pw) return false; if (!function_exists('ldap_connect')) return false; foreach ((array)$pwlist as $ldap) { - if (!preg_match('!ldap://([^:]+)(?::(\\d+))?/(.+)$!', $ldap, $match)) + if (!preg_match('!(ldaps?://([^/]+))?/(.+)$!', $ldap, $match)) continue; - list($z, $server, $port, $path) = $match; + list($z, $server, $path) = $match; list($basedn, $attr, $sub) = explode('?', $path); - if (!$port) $port = 389; if (!$attr) $attr = 'uid'; if (!$sub) $sub = 'one'; $binddn = @$AuthLDAPBindDN; $bindpw = @$AuthLDAPBindPassword; - $ds = ldap_connect($server, $port); + $ds = ldap_connect($server); ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); if (ldap_bind($ds, $binddn, $bindpw)) { $fn = ($sub == 'sub') ? 'ldap_search' : 'ldap_list'; |