core icon indicating copy to clipboard operation
core copied to clipboard

[4.5.11] Some ldap users not shown in share dialog

Open gufete opened this issue 13 years ago • 19 comments

Hello

We are running owncloud 4.5.11+mysql on CentOS 6 x64. We have a ldap backend. We have ldap cache ttl of 24 hours and run the follwing script in cron daily:

#!/usr/bin/php
require_once '/var/www/html/owncloud/lib/base.php';
// Clean cache
$ldap = new \OCA\user_ldap\lib\Connection('user_ldap');
$ldap->clearCache();
// Sync
$GET_SEARCH = 'x';
$limit = 0;
$offset = 0;
$users = OC_User::getUsers($GET_SEARCH, $limit, $offset);

I can see all ldap users in the oc_ldap_user_mapping table. The problem happens when user A tries to share a file with another user. Most of them can be found in the autocomplete share dialog, but other ones do not appear, but they are in the oc_ldap_user_mapping table in mysql.

Example:

User A wants to share a file with user B or user C. In the share dialog user B appears, but not user C, and both are in the oc_ldap_user_mapping table:

mysql> select * from oc_ldap_user_mapping where ldap_dn='uid=userB,o=mysite,dc=we,dc=es';

+--------------------------------+---------------+----------------+
| ldap_dn                        | owncloud_name | directory_uuid |
+--------------------------------+---------------+----------------+
| uid=userB,o=mysite,dc=we,dc=es | userB         |                |
+--------------------------------+---------------+----------------+
1 row in set (0.00 sec)

mysql> select * from oc_ldap_user_mapping where ldap_dn='uid=userB,o=mysite.es,dc=we,dc=es';

+----------------------------- --+---------------+----------------+
| ldap_dn                        | owncloud_name | directory_uuid |
+--------------------------------+---------------+----------------+
| uid=userC,o=mysite,dc=we,dc=es | userC         |                |
+--------------------------------+---------------+----------------+

Any hint?

gufete avatar May 28 '13 07:05 gufete

cc @blizzz @dschmidt

MorrisJobke avatar May 28 '13 11:05 MorrisJobke

Odd, that there is not directory_uuid value, but that ain't the source of the problem. What LDAP server are you running on?

If you use the script, use userC in $GET_SEARCH and var_dump the output, what do you get? Might the user list filter filter out userC?

blizzz avatar May 30 '13 19:05 blizzz

We use Sun One Directory Server 6.3.1 as ldap server.

We have changed the script as you asked:

 {
}
$GET_SEARCH = 'missing_uid';
// ...
$users = OC_User::getUsers($GET_SEARCH, $limit, $offset);
var_dump($users);

This is the output:

array(0)

Regards Javier

gufete avatar May 31 '13 06:05 gufete

More info: I have captured with tcpdump the network traffic to the ldap server and executed the script. In the tcpdump file I can see the ldap entry of userC. The ldap query works. The problem must be inside owncloud.

I have another user D that appears in the tcpdump but cannot be found in the share dialog.

gufete avatar May 31 '13 06:05 gufete

Hi,

I have the same problem - i dont think its in the backend since the user shows correctly in the mysql table - i have a feeling users is not being listed correctly when fetched via ajax.. also - in some cases my users are shown 2-3 times but with empty groups.

Anyone know if there is a way to disable the ajax for user.php ?

leonbollerup avatar Jun 03 '13 13:06 leonbollerup

(on a extra note, it seems to work better when using firefox than eg. chrome/IE and Opera)

leonbollerup avatar Jun 03 '13 13:06 leonbollerup

@gufete could you provide the owncloud.log? it is in the data folder

@leonbollerup Do you also use Sun One Directory Server 6.3.1 ?

blizzz avatar Jun 03 '13 17:06 blizzz

Nope, we use MS Active Directory running on 2008 server, nothing fancy, standard configuration - as said before i dont think its an issue with the LDAP system as such since it shows all the users correct in the mysql, seems like its the listing of users that is messed up

leonbollerup avatar Jun 03 '13 17:06 leonbollerup

@leonbollerup then this is a different issue. It is supposed to work correctly with AD. Please open a new bug report.

blizzz avatar Jun 03 '13 17:06 blizzz

@blizzz , maybe @leonbollerup is another issue... or not. The behaviour is the same, the user appears in the mysql table, but is not shown in the share dialog.

I have uploaded the owncloud.log to http://pastelink.me/dl/194aa4

The debug level is "standard", shoud I use more verbose logging?

gufete avatar Jun 04 '13 06:06 gufete

What is eye-catching is that you have a lot of such errors:

{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":1361172486}

meaning that login failed.

But also of those:

{"app":"user_ldap","message":"Bind failed: -1: Can't contact LDAP server","level":3,"time":1355785854}
{"app":"user_ldap","message":"Connection could not be established","level":3,"time":1355785854}

meaning that the connection to the LDAP server could not been established at all.

Then I see

{"app":"user_ldap","message":"Search: no result resource, LDAP error message: (2) Protocol error, search filter: ","level":3,"time":1358806784}

What are your user list filter settings?

Oh, and again, in one of your earlier postings you gave an excerpt of a database table. What looked odd, was that there is no directory_uuid value. Is it really so or did you just leave it out for some reason?

A log with Level = Debug would be helpful.

blizzz avatar Jun 07 '13 23:06 blizzz

Thank you for your support @blizzz , I have made the following

1º Delete owncloud.log & recreated it. Apache user can write on it

2º More verbose logging, in $WWW/owncloud/config/config.php added this:

define("DEBUG", true); // at the beginning before $CONFIG = array
'loglevel' => '0' //inside $CONFIG array

3º Run php script to "populate" mysql with all users from ldap, and check that all ldap users are there

mysql> select count(*) from oc_ldap_user_mapping;
+----------+
| count(*) |
+----------+
|    24036 |
+----------+
1 row in set (0.00 sec)

4º Review owncloud.log: crated, but empty

5º Try to share a file: still the same, user B appears in dialog, but not user C or D (detailed info about C or D below)

6º owncloud.log empty. Losing faith

ldap settings:

base dn: o=mysite,dc=we,dc=es login user filter: uid=%uid list user filter: (&(objectClass=MySitePerson)(inetUserStatus=Active))

@blizzz , you also asked me about directory_uuid value. From point 5º:

User A wants to share a file with user B or user C or user D. In the share dialog user B appears, but not user C neither D, and both (C & D) are in the oc_ldap_user_mapping table, and D has directory_uuid value

mysql> select * from oc_ldap_user_mapping where ldap_dn='uid=userB,o=mysite,dc=we,dc=es';
+--------------------------------+---------------+----------------+
| ldap_dn                        | owncloud_name | directory_uuid |
+--------------------------------+---------------+----------------+
| uid=userB,o=mysite,dc=we,dc=es | userB         |                |
+--------------------------------+---------------+----------------+
1 row in set (0.00 sec)
mysql> select * from oc_ldap_user_mapping where ldap_dn='uid=userC,o=mysite.es,dc=we,dc=es';
+----------------------------- --+---------------+----------------+
| ldap_dn                        | owncloud_name | directory_uuid |
+--------------------------------+---------------+----------------+
| uid=userC,o=mysite,dc=we,dc=es | userC         |                |
+--------------------------------+---------------+----------------+
mysql> select * from oc_ldap_user_mapping where ldap_dn='uid=userD,o=mysite.es,dc=we,dc=es';
+----------------------------- --+---------------+--------------------------------------+
| ldap_dn                        | owncloud_name | directory_uuid                       |
+--------------------------------+---------------+--------------------------------------+
| uid=userD,o=mysite,dc=we,dc=es | userD         | 017db621-e8d811df-8051d0ad-b1146ac5  |
+--------------------------------+---------------+--------------------------------------+

This issue is driving me nuts: Why some users are shown in the dialog and not others? All of them are in the mysql table, B has empty directory_uuid and is shown. C is not shown, and has also empty directory_uuid. D is not shown, and has a string in directory_uuid.

Thank you for your support.

gufete avatar Jun 10 '13 08:06 gufete

There should definitely appear something in the owncloud.log – on debug level it should be filled with all sorts of stuff. Try this: delete it, but don't recreate it. ownCloud will do it itself.

Is there something special in the DN of userB compared to userC and userD? Whitespaces or other special chars?

blizzz avatar Jun 11 '13 17:06 blizzz

Deleted owncloud.log. Launched php script to "warm up" the ldap cache mapping in mysql. Made a select count(*) to check that all users from ldap are in the mysql table. Then, connected to owncloud web interface and tried to share a file, stille the same: I can nos share with same users.

A, B, C & D users are "normal" users (Javier, Carmen, Pepa, Jorge, standard spanish names, no whitespaces or non-ascii chars)

This time the log is more verbose:

{"app":"user_ldap","message":"Reading the configuration","level":0,"time":1371021774}
{"app":"user_ldap","message":"Base tree for Users is empty, using Base DN","level":1,"time":1371021774}
{"app":"user_ldap","message":"Base tree for Groups is empty, using Base DN","level":1,"time":1371021774}
{"app":"user_ldap","message":"Checking conf state: isConfigured?  isForce?  configID? user_ldap","level":0,"time":1371021776}
{"app":"user_ldap","message":"Reading the configuration","level":0,"time":1371021776}
{"app":"user_ldap","message":"Base tree for Users is empty, using Base DN","level":1,"time":1371021776}
{"app":"user_ldap","message":"Base tree for Groups is empty, using Base DN","level":1,"time":1371021776}
{"app":"user_ldap","message":"Checking conf state: isConfigured? 1 isForce?  configID? user_ldap","level":0,"time":1371021776}
{"app":"user_ldap","message":"readAttribute: uid=userB,o=mysite,dc=we,dc=es found","level":0,"time":1371021776}

Still can not share with user D or C, tough.

gufete avatar Jun 12 '13 07:06 gufete

Any update on this? Still does not work as expected.

gufete avatar Jun 25 '13 06:06 gufete

Sorry, for the delay. If you still have the problem, you can try to remove the DB entries with the users not showing up (remember the username). Next time, the entries should be re-created. Ideally with a UUID. Make sure they have the same owncloud_name as before (if not, change it accordingly). Any changes?

blizzz avatar Aug 16 '13 16:08 blizzz

Hello @blizzz

Still the same. I also have deleted all the mysql table, recreated it (all users have now UUID), repopulated the database (>24000 entries) and still the same: all the users are in the oc_ldap_user_mapping, but not all of them are shown when I tried to share a file.

Do you need any additional info to debug this?

gufete avatar Aug 20 '13 11:08 gufete

It might be that the users are filtered out. To test this, could you please change owncloud/apps/user_ldap/user_ldap.php according to:

diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 063cddf..738f6bd 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -121,7 +121,11 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
        }

        public function userMatchesFilter($user) {
-               return (strripos($user, $this->userSearch) !== false);
+               $isUserOK = (strripos($user, $this->userSearch) !== false);
+               if(!$isUserOK) {
+                       \OCP\Util::writeLog('user_ldap', 'User '.$user.' does not match search filter '.$this->userSearch, \OCP\Util::DEBUG);
+               }
+               return $isUserOK;
        }

        /**

Please run your script again with $GET_SEARCH targeted at the missing users. Per user who is sorted out there will be one line in the owncloud.log. Check it then, please. (You need to have Loglevel set to DEBUG).

blizzz avatar Aug 21 '13 10:08 blizzz

I close it for inactivity. Please reopen if the problem sill exists.

blizzz avatar Oct 22 '13 21:10 blizzz