useUserAccess (useLiveAccess) method while using WCM API

By default users running the custom WCM API applications have at least Contributor role on the objects accessed in the Workspace. This can be lowered to User role using useUserAccess method.


workspace.useUserAccess(true); (in old versions it is useLiveAccess)

true------user Access
false-----contributer access
Note: The Access context used in the API can be set at any time, after the creation of the workspace.

Call "workspace.useUserAccess(true)" before calling other workspace methods that act on objects for which Contributor role would otherwise be required.


Scenarios:


Problem WCM API method workspace.getById() fails for content or library component even though the user is given "User" access.   


Cause This method requires minimum "Contributor" access on wcm content or library component to get desired results.  


Resolving the problem In order to resolve this issue , call API method "workspace.useUserAccess(true)" just before calling the workspace.getById() method . Otherwise , the default access context is "Contributor" and hence method workspace.getById() fails for content or library component even though the user is given "User" access. 





Resources:
Authorizationexception is thrown while using workspace.getById() method (https://www-304.ibm.com/support/docview.wss?uid=swg21399507)

No comments:

Post a Comment