On Fri, Sep 20, 2013 at 9:30 PM, Christian Fiddick <christian.fiddick@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-au...) 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/xwik... 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/xwik...
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@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne