Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/Group.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/Group.pm	(revision 91)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/Group.pm	(revision 92)
@@ -39,8 +39,13 @@
 sub _key_attr { 'cn' } 
 
+sub _delayed_fields {
+    my ($self)= @_;
+    return qw(memberUID member);
+}
+
 sub _canonical_fields {
     my ($self, $base, $mode) = @_;
     (
-        qw(gidNumber description sAMAccountName member),
+        qw(gidNumber description sAMAccountName member memberUID),
         ($mode !~ /w/
             ? qw(cn dn)
@@ -84,5 +89,10 @@
             },
         );
+        sort(@res);
         return \@res
+    };
+    $field eq 'memberUID' and do {
+        my $val = $self->SUPER::get_field($field);
+        return ref $val ? $val : [ grep { $_ } $val ];
     };
     $self->SUPER::get_field($field);
@@ -93,4 +103,23 @@
     my %ndata;
     while (my ($f, $val) = each(%data)) {
+        $f eq 'memberUID' and do {
+            my %users;
+            $users{$_}{e} = 1 foreach (@{ $self->get_field('memberUID') || []});
+            $users{$_}{n} = 1 foreach (@{ $val || []});
+            foreach (keys %users) {
+                $users{$_}{e} && $users{$_}{n} and next;
+                my $user = $self->base->get_object('user', $_) or next;
+                if ($users{$_}{e}) {
+                    $self->{entry}->del(memberUID => $_);
+                } elsif ($users{$_}{n}) {
+                    $self->{entry}->add(memberUID => $_);
+                } # else {} # can't happen
+                my $mesg = $self->{entry}->update($self->base->ldap);
+                if ($mesg->code) {
+                    warn $mesg->error;
+                }
+            }
+            next;
+        };
         $f eq 'member' and do {
             my %users;
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm	(revision 91)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm	(revision 92)
@@ -39,4 +39,9 @@
 sub _key_attr { 'cn' } 
 
+sub _delayed_fields {
+    my ($self)= @_;
+    return qw(memberOf);
+}
+
 sub _canonical_fields {
     my ($self, $base, $mode) = @_;
@@ -55,7 +60,8 @@
         ipPhone otherTelephone department
         title modbile homePhone
+        memberOf
         ),
         ($mode !~ /w/
-            ? qw(cn dn uSNCreated uSNChanged memberOf)
+            ? qw(cn dn uSNCreated uSNChanged)
             : ()
         )
@@ -92,4 +98,55 @@
 }
 
+sub get_field {
+    my ($self, $field) = @_;
+
+    $field eq 'memberOf' and do {
+        my @res;
+        $self->base->_unlimited_search(
+            base => $self->base->object_base_dn('group'),
+            filter => sprintf(
+                '(&(objectClass=group)(member=%s))',
+                escape_filter_value($self->{entry}->dn),
+            ),
+            callback => sub {
+                my ($mesg, $entry) = @_;
+                ref $entry eq 'Net::LDAP::Entry' or return;
+                push(@res, $entry->get_value('cn'));
+            },
+        );
+        sort(@res);
+        return \@res
+    };
+    $self->SUPER::get_field($field);
+}
+
+sub set_fields {
+    my ($self, %data) = @_;
+    my %ndata;
+    while (my ($f, $val) = each(%data)) {
+        $f eq 'memberOf' and do {
+            my %users;
+            $users{$_}{e} = 1 foreach (@{ $self->get_field('memberOf') || []});
+            $users{$_}{n} = 1 foreach (@{ $val || []});
+            foreach (keys %users) {
+                $users{$_}{e} && $users{$_}{n} and next;
+                my $user = $self->base->get_object('group', $_) or next;
+                if ($users{$_}{e}) {
+                    $self->{entry}->del(memberOf => $user->get_field('dn'));
+                } elsif ($users{$_}{n}) {
+                    $self->{entry}->add(memberOf => $user->get_field('dn'));
+                } # else {} # can't happen
+                my $mesg = $self->{entry}->update($self->base->ldap);
+                if ($mesg->code) {
+                    warn $mesg->error;
+                }
+            }
+            next;
+        };
+        $ndata{$f} = $val;
+    }
+    $self->SUPER::set_fields(%ndata);
+}
+
 1;
 
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/objects.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/objects.pm	(revision 91)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/objects.pm	(revision 92)
@@ -108,5 +108,6 @@
 
     $field eq 'dn' and return $self->{entry}->dn;
-    return $self->{entry}->get_value($field);
+    my ($first, @others) = $self->{entry}->get_value($field);
+    return @others ? [ sort($first, @others) ] : $first;
 }
 
@@ -132,61 +133,4 @@
 }
 
-sub get_group_users {
-    my ($self, $groupname, @searchargs) = @_;
-    my $gr = $self->get_group($groupname, attrs => [ qw(cn member) ]);
-
-    my @res;
-    foreach my $dnu (@{ $gr->get_value('member', asref => 1) || [] }) {
-        my $mesg = $self->search(
-            filter => '(objectClass=*)', # TODO can we get something else than user ?
-            @searchargs,
-            base => $dnu,
-        );
-
-        $mesg->code and return; # ensure error is propagate here
-        foreach my $entry ($mesg->entries) {
-           push(@res, $entry);
-       } 
-    }
-    @res
-}
-
-sub get_user_groups {
-    my ($self, $username, @searchargs) = @_;
-    my $user = $self->get_user($username);
-
-    my @res;
-    $self->unlimited_search(
-        base => $self->top_dn,
-        filter => sprintf(
-            '(&(objectClass=group)(member=%s))',
-            escape_filter_value($user->dn),
-        ),
-        @searchargs,
-        callback => sub {
-            my ($mesg, $entry) = @_;
-            ref $entry eq 'Net::LDAP::Entry' or return;
-            push(@res, $entry);
-        },
-    );
-
-    @res
-}
-
-sub add_user_group {
-    my ($self, $username, $groupname) = @_;
-
-    my $user = $self->get_user($username) or return;
-    my $group = $self->get_group($groupname) or return;
-
-    $group->add(member => $user->dn);
-
-    my $mesg = $group->update($self);
-    if ($mesg->code) {
-        warn $mesg->error;
-        return;
-    } else { return 1 };
-}
-
 1;
 
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm	(revision 91)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm	(revision 92)
@@ -42,4 +42,9 @@
 
 sub has_extended_attributes { 1 }
+
+sub _delayed_fields {
+    my ($self)= @_;
+    return qw(memberOf);
+}
 
 sub _inline_fields {
