Hi again,

On 09/19/2012 02:25 AM, Manuel Delgado wrote:
I think the problem is not in the ldap but in the greedy
(foreach/recursive) search in ldap2ownCloudNames method.

I have two other approaches which work around the recursive array search. One is simple improving the result array from mappedComponents so that a simple $arr[$dn] will give the owncloud name, if set.

The other does DB queries using a prepared statement (i.e. i hope MDB2 does prepared statements) on request.

Both changesets (each against access.php from git master) are attached. Could you please test if they speed it up noticeably, and if so which does it better?

Cheers
Arthur


Regards,
Manuel Delgado

-----------------------------------------------------------
*Usuario Linux* *#520940 <http://counter.li.org/>*

Bach. Computación e Informática
Universidad de Costa Rica





On Tue, Sep 4, 2012 at 9:54 PM, Manuel Delgado <[email protected]>wrote:

Exactly, I'm trying to access Settings/Users page, but it never load.
That's why I'm asking how does the cache work, because all the 109.402 user
entries and 25 groups are in the database but a heavy work still there.

As far as I know the cache resides in a file (not in DB), where is it or
how is it stored? and why not to use DB?


Manuel Delgado




On Tue, Sep 4, 2012 at 6:27 PM, Michael Gapczynski <[email protected]>wrote:

What do you mean by trying to make a simple list? The problem areas of
sharing
and the Settings -> Users page were rewritten to fix the performance
issues by
loading in batches.

I think LDAP may still have to load all the users once to populate the
cache.
Arthur will be able to answer your question better, but he is away right
now.


Michael

On Tuesday, September 04, 2012 06:21:52 PM Manuel Delgado wrote:
Hi!

I'm trying again with the Owncloud 4.5 Beta (Well actually the master
branch) and I have almost the same issue... the CPU of my server goes to
100% when I try to make a simple list or query over the LDAP users.
Actually it loops until time is up...

How does the cache work?

Another issue, I think there's a mistyped in
apps/user_ldap/lib/access.php
line 388, it reads:
$sqlAdjustment = 'FROM `dual`';
And it should be:
$sqlAdjustment = 'FROM DUAL';
Otherwise it throws a syntax error on MySQL

Regards,
Manuel Delgado

-----------------------------------------------------------
*Usuario Linux* *#520940 <http://counter.li.org/>*

Bach. Computación e Informática
Universidad de Costa Rica

On Fri, Aug 10, 2012 at 3:33 AM, Arthur Schiwon <[email protected]>
wrote:
On 08/10/2012 09:02 AM, Dirk Kastens wrote:
Hi Manual,

  When I set the size limit, ldap_serch will only return X entries, so

autocompletion will only work on those X entries and I'll be unable
to
share the file with anyone beyond X.

Is this right? or am I missing something?

Theoretically you're right. But with autocompletion, the more letters
you type, the less users will match. For example, you will share a
file
with user tomcat: you type "t" and will get a list of 100 users out
of
2000 that start with a "t". Then you type "o" and now you will see
all
50 users that start with "to". This is the way autocompletion works
with
SOGo. But if owncloud will only use the initial list of users that is
found after typing the first letter, this will not work. So it
depends
on how owncloud's autocompletion is implemented.

Unfortunately it is like this, yet. As Michael said, we're working on
a
better implementation with OC 5.

Cheers
Arthur

Dirk



______________________________**_________________
Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/**listinfo/owncloud<
https://mail.kde.org/mai
lman/listinfo/owncloud>>>
  ______________________________**_________________

Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/**listinfo/owncloud<
https://mail.kde.org/mail
man/listinfo/owncloud>






_______________________________________________
Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/owncloud

diff --git apps/user_ldap/lib/access.php apps/user_ldap/lib/access.php
index 53619ab..439e313 100644
--- apps/user_ldap/lib/access.php
+++ apps/user_ldap/lib/access.php
@@ -295,22 +295,53 @@ abstract class Access {
 		return $this->ldap2ownCloudNames($ldapGroups, false);
 	}
 
+	private function findMappedUser($dn) {
+		static $query = null;
+		if(is_null($query)) { 
+			$query = \OCP\DB::prepare('
+				SELECT `owncloud_name`
+				FROM `'.$this->getMapTable(true).'`
+				WHERE `ldap_dn` = ?'
+			);
+		}
+		$res = $query->execute(array($dn))->fetchOne();
+		if($res) {
+			return  $res;
+		}
+		return false;
+	}
+
+	private function findMappedGroup($dn) {
+                static $query = null;
+		if(is_null($query)) {
+			$query = \OCP\DB::prepare('
+                        	SELECT `owncloud_name`
+	                        FROM `'.$this->getMapTable(false).'`
+        	                WHERE `ldap_dn` = ?'
+                	);      
+		}
+                $res = $query->execute(array($dn))->fetchOne();
+                if($res) {
+                        return  $res;
+                }
+		return false;
+        }
+
+
 	private function ldap2ownCloudNames($ldapObjects, $isUsers) {
 		if($isUsers) {
-			$knownObjects = $this->mappedUsers();
 			$nameAttribute = $this->connection->ldapUserDisplayName;
+			$fncFindMappedName = 'findMappedUser';
 		} else {
-			$knownObjects = $this->mappedGroups();
 			$nameAttribute = $this->connection->ldapGroupDisplayName;
+			$fncFindMappedName = 'findMappedGroup';
 		}
 		$ownCloudNames = array();
 
 		foreach($ldapObjects as $ldapObject) {
-			$key = \OCP\Util::recursiveArraySearch($knownObjects, $ldapObject['dn']);
-
-			//everything is fine when we know the group
-			if($key !== false) {
-				$ownCloudNames[] = $knownObjects[$key]['owncloud_name'];
+			$ocname = $this->$fncFindMappedName($ldapObject['dn']);
+			if($ocname) {
+				$ownCloudNames[] = $ocname;
 				continue;
 			}
 
@@ -654,4 +685,4 @@ abstract class Access {
 		}
 		return $uuid;
 	}
-}
\ No newline at end of file
+}
diff --git apps/user_ldap/lib/access.php apps/user_ldap/lib/access.php
index 53619ab..438dce0 100644
--- apps/user_ldap/lib/access.php
+++ apps/user_ldap/lib/access.php
@@ -306,11 +306,11 @@ abstract class Access {
 		$ownCloudNames = array();
 
 		foreach($ldapObjects as $ldapObject) {
-			$key = \OCP\Util::recursiveArraySearch($knownObjects, $ldapObject['dn']);
-
+			$ocname = isset($knownObjects[$ldapObject['dn']]) ? $knownObjects[$ldapObject['dn']] : false;
+			
 			//everything is fine when we know the group
-			if($key !== false) {
-				$ownCloudNames[] = $knownObjects[$key]['owncloud_name'];
+			if($ocname) {
+				$ownCloudNames[] = $ocname;
 				continue;
 			}
 
@@ -365,8 +365,12 @@ abstract class Access {
 			SELECT `ldap_dn`, `owncloud_name`
 			FROM `'. $table . '`'
 		);
-
-		return $query->execute()->fetchAll();
+		$res = $query->execute();
+		$mappedArray = array();
+		while(($row = $res->fetchOne())) {
+			$mappedArray[$row['ldap_dn']] = $row['owncloud_name'];
+		}
+		return $mappedArray;
 	}
 
 	/**
@@ -654,4 +658,4 @@ abstract class Access {
 		}
 		return $uuid;
 	}
-}
\ No newline at end of file
+}
_______________________________________________
Owncloud mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/owncloud

Reply via email to