Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 162)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm	(revision 163)
@@ -70,14 +70,14 @@
             my $sth = $self->db->prepare_cached(
                 q{
-                select id from user_attributes_groups
-                join user_attributes_list on
-                user_attributes_groups.attr = user_attributes_list.ikey
-                where value = ? and canonical = ?
+                select value from group_attributes_users
+                join group_attributes_list on
+                group_attributes_users.attr = group_attributes_list.ikey
+                where id = ? and canonical = ?
                 }
             );
-            $sth->execute($self->id, 'memberOf');
+            $sth->execute($self->id, 'memberUID');
             my @res;
             while (my $res = $sth->fetchrow_hashref) {
-                push(@res, $res->{id});
+                push(@res, $res->{value});
             }
             return \@res;
@@ -92,6 +92,5 @@
     foreach my $attr (keys %data) {
         $attr =~ /^memberUID$/ and do {
-            my $cl = $self->base->_load_obj_class('user') or next;
-            my $attrid = $cl->_get_field_name_db('memberOf', $self->base) or next;
+            my $attrid = $self->_get_field_name_db('memberUID', $self->base) or next;
             my %member;
             foreach (@{ $self->get_field('memberUID') }) {
@@ -107,10 +106,10 @@
                 if ($member{$_}{n}) {
                     my $sth = $self->db->prepare_cached(
-                        q{insert into user_attributes_groups (id, attr, value) values (?,?,?)}
+                        q{insert into group_attributes_users (value, attr, id) values (?,?,?)}
                     );
                     $sth->execute($_, $attrid, $self->id);
                 } elsif ($member{$_}{c}) {
                     my $sth = $self->db->prepare_cached(
-                        q{delete from user_attributes_groups where id = ? and attr = ? and value = ?}
+                        q{delete from group_attributes_users where value = ? and attr = ? and id = ?}
                     );
                     $sth->execute($_, $attrid, $self->id);
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm	(revision 162)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm	(revision 163)
@@ -74,14 +74,14 @@
         my $sth = $self->db->prepare_cached(
             q{
-            select value from user_attributes_groups
-            join user_attributes_list on
-            user_attributes_groups.attr = user_attributes_list.ikey
-            where id = ? and canonical = ?
+            select id from group_attributes_users
+            join group_attributes_list on
+            group_attributes_users.attr = group_attributes_list.ikey
+            where value = ? and canonical = ?
             }
         );
-        $sth->execute($self->id, 'memberOf');
+        $sth->execute($self->id, 'memberUID');
         my @res;
         while (my $res = $sth->fetchrow_hashref) {
-            push(@res, $res->{value});
+            push(@res, $res->{id});
         }
         return \@res;
@@ -124,5 +124,6 @@
     foreach my $attr (keys %data) {
         $attr =~ /^memberOf$/ and do {
-            my $attrid = $self->_get_field_name_db('memberOf', $self->base) or next;
+            my $cl = $self->base->_load_obj_class('group') or next;
+            my $attrid = $cl->_get_field_name_db('memberUID', $self->base) or next;
             my %member;
             foreach (@{ $self->get_field('memberOf') }) {
@@ -138,10 +139,10 @@
                 if ($member{$_}{n}) {
                     my $sth = $self->db->prepare_cached(
-                        q{insert into user_attributes_groups (id, attr, value) values (?,?,?)}
+                        q{insert into group_attributes_users (value, attr, id) values (?,?,?)}
                     );
                     $sth->execute($self->id, $attrid, $_);
                 } elsif ($member{$_}{c}) {
                     my $sth = $self->db->prepare_cached(
-                        q{delete from user_attributes_groups where id = ? and attr = ? and value = ?}
+                        q{delete from group_attributes_users where value = ? and attr = ? and id = ?}
                     );
                     $sth->execute($self->id, $attrid, $_);
