{"action":"created","issue":{"url":"https://api.github.com/repos/nextcloud/server/issues/6807","repository_url":"https://api.github.com/repos/nextcloud/server","labels_url":"https://api.github.com/repos/nextcloud/server/issues/6807/labels{/name}","comments_url":"https://api.github.com/repos/nextcloud/server/issues/6807/comments","events_url":"https://api.github.com/repos/nextcloud/server/issues/6807/events","html_url":"https://github.com/nextcloud/server/issues/6807","id":264372332,"number":6807,"title":"Sharing dialog returns duplicate entries","user":{"login":"rogerfv1","id":18149101,"avatar_url":"https://avatars3.githubusercontent.com/u/18149101?v=4","gravatar_id":"","url":"https://api.github.com/users/rogerfv1","html_url":"https://github.com/rogerfv1","followers_url":"https://api.github.com/users/rogerfv1/followers","following_url":"https://api.github.com/users/rogerfv1/following{/other_user}","gists_url":"https://api.github.com/users/rogerfv1/gists{/gist_id}","starred_url":"https://api.github.com/users/rogerfv1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogerfv1/subscriptions","organizations_url":"https://api.github.com/users/rogerfv1/orgs","repos_url":"https://api.github.com/users/rogerfv1/repos","events_url":"https://api.github.com/users/rogerfv1/events{/privacy}","received_events_url":"https://api.github.com/users/rogerfv1/received_events","type":"User","site_admin":false},"labels":[{"id":386379231,"url":"https://api.github.com/repos/nextcloud/server/labels/bug","name":"bug","color":"ee0701","default":true},{"id":389031994,"url":"https://api.github.com/repos/nextcloud/server/labels/feature:%20sharing","name":"feature: sharing","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-10-10T20:53:09Z","updated_at":"2018-03-01T20:11:06Z","closed_at":null,"author_association":"NONE","body":"### Steps to reproduce\r\n1. Configure ldap_expert_uuid_user_attr = uid on user_ldap plugin\r\n2. Use numeric/values for uid atribute in LDAP Server\r\n\r\n### Expected behaviour\r\nSharing dialog should display unique users/contacts.\r\n\r\n### Actual behaviour\r\nSharing dialog returns some duplicate users/contacts entries.\r\n\r\n### Server configuration\r\n\r\n**Operating system**: Debian 8\r\n\r\n**Web server:** Apache 2.4\r\n\r\n**Database:** Postgresql 9.4\r\n\r\n**PHP version:** php 5.6\r\n\r\n**Nextcloud version:** 12.0.3\r\n\r\n**Are you using external storage, if yes which one:** no\r\n\r\n**Are you using encryption:** no\r\n\r\n**Are you using an external user-backend, if yes which one:** LDAP\r\n\r\nWe looked at the source code and we found a issue when using numeric/integer values for 'uid'.\r\nAn array of users, groups and contacts is created on every search. Before it is shown to the enduser, the array values are compared in search of duplicated entries. The function \"hasUserInResult\" isn't working properly when the uid attribute from AD/LDAP is a integer. The problem seems to be that PHP  is type casting the LDAP attribute 'uid' from string to integer.\r\n\r\nFile: /var/www/nextcloud/apps/files_sharing/lib/Controller/ShareesAPIController.php\r\n\r\n        protected function hasUserInResult($userId) {\r\n                foreach ($this->result['exact']['users'] as $result) {\r\n                        if ($result['value']['shareWith'] === $userId) {\r\n                                return true;\r\n                        }\r\n                }\r\n                foreach ($this->result['users'] as $result) {\r\n                        if ($result['value']['shareWith'] === $userId) { //  <---- sometimes we get identical values but different types INTEGER  === STRING\r\n                                return true;\r\n                        }\r\n                }\r\n                return false;\r\n        }\r\n\r\n        protected function getUsers($search) {\r\n                        .....\r\n                        .....\r\n                        // Search in all users\r\n                        $usersTmp = $this->userManager->searchDisplayName($search, $this->limit, $this->offset);\r\n\r\n                        foreach ($usersTmp as $user) {\r\n                                $users[$user->getUID()] = $user->getDisplayName();  //  <---- creating keys with type integer\r\n                        }\r\n                        .....\r\n                        .....\r\n        }\r\n\r\n\r\nExample Code to simulate the issue:\r\n\r\n```javascript\r\n<?php\r\n$all = Array (\r\n    'users' => Array (\r\n                 0 => Array (\r\n                     'label' => 'Mary',\r\n                     'value' => Array ( 'shareType' => 0, 'shareWith' => '02222222222' )\r\n                 ),\r\n                 1 => Array (\r\n                     'label' => 'Jean',\r\n                     'value' => Array ( 'shareType' => 0, 'shareWith' => '22222222222' )\r\n                 )\r\n             )\r\n         );\r\nforeach ($all['users'] as $user) {\r\n  $uid = $user['value']['shareWith'];\r\n  $users[$uid] = 'nome';\r\n}\r\nforeach ($users as $key => $value) {\r\n  echo \"keyValue:\".$key.\" keyType:\".gettype($key).\"\\n\";\r\n}\r\n?>\r\n```\r\n\r\n\r\n**Workaround**:\r\n\r\n    Maybe change the comparison operator in hasUserInResult function to \"==\".\r\n    $result['value']['shareWith'] == $userId"},"comment":{"url":"https://api.github.com/repos/nextcloud/server/issues/comments/369715795","html_url":"https://github.com/nextcloud/server/issues/6807#issuecomment-369715795","issue_url":"https://api.github.com/repos/nextcloud/server/issues/6807","id":369715795,"user":{"login":"snab","id":8182536,"avatar_url":"https://avatars0.githubusercontent.com/u/8182536?v=4","gravatar_id":"","url":"https://api.github.com/users/snab","html_url":"https://github.com/snab","followers_url":"https://api.github.com/users/snab/followers","following_url":"https://api.github.com/users/snab/following{/other_user}","gists_url":"https://api.github.com/users/snab/gists{/gist_id}","starred_url":"https://api.github.com/users/snab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snab/subscriptions","organizations_url":"https://api.github.com/users/snab/orgs","repos_url":"https://api.github.com/users/snab/repos","events_url":"https://api.github.com/users/snab/events{/privacy}","received_events_url":"https://api.github.com/users/snab/received_events","type":"User","site_admin":false},"created_at":"2018-03-01T20:11:06Z","updated_at":"2018-03-01T20:11:06Z","author_association":"NONE","body":"This problem seems to be solved with Nextcloud 13. :-) :+1: "}}
{"actor":{"display_login":"snab"}}