Thanks so much Thomas.
-----Original Message-----
From: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] On Behalf Of Thomas
Mortagne
Sent: Sunday, September 22, 2013 10:16 AM
To: XWiki Users
Subject: Re: [xwiki-users] Adding a user to groups in Java
On Fri, Sep 20, 2013 at 9:30 PM, Christian Fiddick
<christian.fiddick(a)validusholdings.com> wrote:
Hello,
This has frustrated me to no end. I have a custom authenticator based on the http example
(
https://github.com/xwiki-contrib/sandbox/blob/master/authenticators/xwiki-a…)
and it works well, except for one thing.
In the linked code, you'll see a method syncUser that creates the user if necessary.
I would like to modify this section to place the user in more than one global group. Here
is my best attempt:
// Right after the createUser() call...
XWikiGroupService groupService =
context.getWiki().getGroupService(context);
groupService.addUserToGroup(validUserFullName, context.getDatabase(),
"XWiki.SomeGroup", context);
groupService.addUserToGroup(validUserFullName, context.getDatabase(),
"XWiki.AnotherGroup", context);
Here is the javadoc of #addUserToGroup:
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
This method just update the cache (which is actually pretty useless since it's updated
automatically by listening to document modification events so we should probably deprecate
it) and does not really add the user to the group. There is no real API to do that
directly so you will have to do it "by hand", meaning adding an object of class
XWiki.XWikiGroups to the group document with the user id in it.
If you want another authenticator that does it you can look at the LDAP one: more
specifically
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
But this is just creating the users. If I log in as superadmin and check the groups, they
are empty. Any ideas?
Thanks!!
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users