[xwiki-devs] How can I dynamically add group rights to a space?
Ludovic Dubost
ludovic at xwiki.org
Mon Mar 31 19:40:32 CEST 2008
Hi,
I don't see how this code would lock you out.
Especially the superadmin activated in xwiki.cfg should be able to log
in and view any pages.
Other users should still be able to see pages in spaces not being spaceName
Was spaceName == XWiki. In that case try viewing pages with ?xpage=plain
to make sure
Ludovic
Glenn Everitt wrote:
> Whoops..
> Well here is what I coded but it did something really bad - I can't even log
> in with superadmin. I guess I trashed the main XWiki.XWikiGlobalRight
> somehow. So is there a way to recover or do just need to reinstall? or
> could I just import an old export. Any hints on where I went wrong would be
> a big help.
>
> WARNING DO NOT USE THIS CODE!
>
> XWikiDocument spaceDoc = context.getWiki().getDocument(spaceName+
> "." + "WebPreferences", context);
> spaceDoc.setParent("");
> spaceDoc.setAuthor("UGM");
> context.getWiki().saveDocument(spaceDoc, "UGM Created Space",
> context);
>
> BaseObject rightsObject =
> spaceDoc.getObject("XWiki.XWikiGlobalRights", true, context);
> rightsObject.setLargeStringValue("groups", wikiGroupName);
> rightsObject.setStringValue("levels", "view");
> rightsObject.setLargeStringValue("users", "");
> rightsObject.setIntValue("allow", 1);
> context.getWiki().saveDocument(spaceDoc,
> context.getMessageTool().get("core.comment.createdUser"), context);
>
> Thanks again
> Glenn Everitt
>
>
> Thomas Mortagne wrote:
>
>> Hi,
>>
>> On Mon, Mar 31, 2008 at 4:45 AM, Glenn Everitt
>> <Glenn.Everitt at compuware.com> wrote:
>>
>>> I've got existing groups of users in a proprietary system and I want to
>>> automatically create a new XWiki user and if this is the first user in
>>> the
>>> group I want to create a XWiki Space and an XWiki group. Finally, I want
>>> to
>>> authorize the XWiki Group within the XWiki Space.
>>>
>>> I can create the user similar to the CreateUserFromLDAP and I can create
>>> a
>>> group by creating a new XWikiDocument and adding a GroupClass object to
>>> it.
>>> Then I can add the user into the group by using
>>> XWikiGroupService.addUserToGroup. Next, I can create the space using
>>> SpaceManagerPluginApi.createSpace but I don't know how to give the group
>>> justed added rights in the space just added.
>>>
>>> I think I should use Xwiki.XWikiRights and Xwiki.XWikiGlobalRights but I
>>> can't figure out how to do this.
>>> I want to give Access Level rights to the added Group for the added
>>> Space.
>>>
>> Look at http://code.xwiki.org/xwiki/bin/view/Snippets/SettingRightsSnippet
>> for an example of how to configure a XWiki.XWikiRights (same as
>> XWiki.XWikiGlobalRights but on different scope) object.
>>
>> For you particular case you should edit <Space>.WebPreferences (where
>> are listed space rights) and edit/add XWiki.XWikiGlobalRights (because
>> you want to "globally" configure <Space> and not configure just
>> <Space>.WebPreferences document).
>>
>>
>>> It would be great if someone could point me to an example or explanation
>>> of
>>> how to use XWikiRights.
>>>
>>> Help is always appreciated.
>>> Thanks
>>> Glenn Everitt
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-can-I-dynamically-add-group-rights-to-a-space--tp16390961p16390961.html
>>> Sent from the XWiki- Dev mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> devs mailing list
>>> devs at xwiki.org
>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>
>>>
>>
>> --
>> Thomas Mortagne
>> _______________________________________________
>> devs mailing list
>> devs at xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>>
>>
>
>
--
Ludovic Dubost
Blog: http://blog.ludovic.org/
XWiki: http://www.xwiki.com
Skype: ldubost GTalk: ldubost
More information about the devs
mailing list