LDAP App
While installing LDAP app and configuring it for my OpenLDAP directory I stumbled onto a number of bugs. Most I was able to monkey patch myself using Google. Now I am stuck at the following message in log file.
{"app":"user_ldap","message":"Turned off SSL certificate validation successfully.","level":2,"time":"2014-07-25T05:24:14+00:00"} {"app":"PHP","message":"Call to a member function getUsername() on a non-object at /var/www/owncloud/apps/user_ldap/user_ldap.php#69","level":3,"time":"2014-07-25T05:24:14+00:00"}
This code is $user = $this->access->userManager->get($dn); if($user->getUsername() !== false) {
I'm not sure that that my DN is passed correctly. It seems to be in there twice. I also saw that in other code but in those cases there was : between the two strings.
Is OpenLDAP a supported directory? Because my setup is very standard and simple. I have not been able to pinpoint the exact location of the bug but I think this problem will reproduce on any OpenLDAP config.
public function checkPassword($uid, $password) {
$uid = $this->access->escapeFilterPart($uid);
//find out dn of the user name
$filter = \OCP\Util::mb_str_replace(
'%uid', $uid, $this->access->connection->ldapLoginFilter, 'UTF-8');
$ldap_users = $this->access->fetchListOfUsers($filter, 'dn');
if(count($ldap_users) < 1) {
return false;
}
$dn = $ldap_users[0];
$user = $this->access->userManager->get($dn);
if($user->getUsername() !== false) {
//are the credentials OK?
if(!$this->access->areCredentialsValid($dn, $password)) {
return false;
}
$user->markLogin();
return $user->getUsername();
}
return false;
}
@blizzz
I have the same problem, I updated my testserver from 6.0.4 (ldap worked !) to 7.0.0 and get the very same error message.
Could it be that the new LDAP App makes some false assumptions about DN structure?
Our DN's look like this:
CN=Username,OU=Local,OU=Personen,O=physik
@blizzz
it is necessary to allow more variants in the DN structure, there are some different way how LDAP can be setup.
This patch solves my problem:
*** manager.php 2014-07-22 22:00:13.000000000 +0200
--- /var/www/html/owncloud/apps/user_ldap/lib/user/manager.php 2014-07-25 09:10:25.875000117 +0200
***************
*** 144,150 ****
}
if(strpos(mb_strtolower($id, 'UTF-8'), 'dc=') === false
! && strpos(mb_strtolower($id, 'UTF-8'), 'uid=') === false ) {
//most likely a uid
$dn = $this->access->username2dn($id);
if($dn !== false) {
--- 144,153 ----
}
if(strpos(mb_strtolower($id, 'UTF-8'), 'dc=') === false
! && strpos(mb_strtolower($id, 'UTF-8'), 'uid=') === false
! && strpos(mb_strtolower($id, 'UTF-8'), 'o=') === false
! && strpos(mb_strtolower($id, 'UTF-8'), 'cn=') === false
! && strpos(mb_strtolower($id, 'UTF-8'), 'ou=') === false ) {
//most likely a uid
$dn = $this->access->username2dn($id);
if($dn !== false) {
Works for me. Thanks!
Too soon.
I think the patch worked. Or, in any case, it changed the error message. I was unable to login as a result of password failure. But after restarting the browser (not sure if that had anything to do with it), the message is back.
I check the code, the patch is still there. Just no longer working.
I think we are reaching the bottom line. I have worked for 6 hours or so on issues related to OpenLDAP integration. The LDAP integration is sort of a key issue. Without it we need to look elsewhere.
Too many issues.
the ldap wizard is very clumsy, what is the structure of your DN's?
My user is cn=My Full Name,ou=people,dc=mydomain,dc=com and my group is cn=owncloud-users,ou=groups,dc=mydomain,dc=com
I configured and used uid to log in.
On Fri, Jul 25, 2014 at 10:05 AM, ksteinb [email protected] wrote:
the ldap wizard is very clumsy, what is the structure of your DN's?
— Reply to this email directly or view it on GitHub https://github.com/owncloud/core/issues/9887#issuecomment-50119684.
@blizzz 7.0.1 is again missing this patch!
Please try https://github.com/owncloud/core/pull/10340 this does not require a fixed/expected DN structure
submitted to test
:+1:
What's the fix? Will there be an update releasing for this fix?
As written few comments above the fix is https://github.com/owncloud/core/pull/10340
It will be included in 7.0.2, which will be released not before Aug 25th.
Ok, thank you!
Not sure if this fix was included in the last release. I'm still getting a white page when an ldap user authenticates.
@airforceboricua it is. Does the "Call to a member function getUsername() on a non-object" still appear in your log?
@blizz, yes, it does.
{"app":"PHP","message":"Call to a member function getUsername() on a non-object at /var/www/owncloud/apps/user_ldap/user_ldap.php#69","level":3,"time":"2014-08-27T18:37:49+00:00"}
Here is the version:
$ dpkg -l | grep owncloud ii owncloud 7.0.2-1 ownCloud Server - Private file sync and share server
I am also getting a white page when an ldap user authenticates after applied all the patches.
Here is the log:
{"reqId":"53ff7c5f0891c","app":"PHP","message":"ldap_start_tls(): Unable to start TLS: Protocol error at /var/www/owncloud/apps/user_ldap/lib/ldap.php#252","level":3,"time":"2014-08-28T19:00:47+00:00","method":"POST","url":"/owncloud/"} {"reqId":"53ff7c5f0891c","app":"user_ldap","message":"LDAP error Protocol error (2) after calling ldap_start_tls","level":0,"time":"2014-08-28T19:00:47+00:00","method":"POST","url":"/owncloud/"} {"reqId":"53ff7c5f0891c","app":"PHP","message":"Call to a member function getUsername() on a non-object at /var/www/owncloud/apps/user_ldap/user_ldap.php#69","level":3,"time":"2014-08-28T19:00:47+00:00","method":"POST","url":"/owncloud/"}
$ dpkg -l | grep owncloud ii owncloud 7.0.1-0 ownCloud Server - Private file sync and share server ii owncloud-mysql 5.0.4debian-0ubuntu1~ubuntu12.04 meta-package providing MySQL dependencies for ownCloud
@airforceboricua can you apply this
diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php
index 0ed3d09..2ac7691 100644
--- a/apps/user_ldap/lib/user/manager.php
+++ b/apps/user_ldap/lib/user/manager.php
@@ -143,7 +143,7 @@ class Manager {
return $this->users['byUid'][$id];
}
- if(!$this->access->stringResemblesDN($id) ) {
+ if(!($res = $this->access->stringResemblesDN($id)) ) {
//most likely a uid
$dn = $this->access->username2dn($id);
if($dn !== false) {
@@ -161,6 +161,10 @@ class Manager {
if($dn !== false) {
return $this->createAndCache($dn, $id);
}
+
+ var_dump($id);
+ var_dump($res);
+ die;
return null;
}
re-attempt the login and paste the output (will be two values on blank page).
@tonylixu you seem to have an TLS issue instead. Also, please test with the latest (maintenance) release.