Answered by:
CRM 2011 - JScript permissions

Question
-
I wonder if there is a way of executing some JScript code that reads or writes records using permissions not owned by the current user.
For example, I made a JS function that cancels other user's activity under certain conditions, and it doesn't work unless the current user has the permission for writing activities other than his own. But I don't want to grant this pemission. I was thinking of something like SQL Server's Execute As. Can I do something like that?
Thanks in advance!
Wednesday, December 5, 2012 3:30 PM
Answers
-
Hi,
As far as I know there is no possibility to execute JScript-statements against the crm server with other permissions as the ones of the current user.
To solve your problem you can use a plugin and run this plugin as another user who has more permissions.
Best regards,
AndreasAndreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- Proposed as answer by JLattimerMVP, Moderator Wednesday, December 5, 2012 6:13 PM
- Marked as answer by JLattimerMVP, Moderator Tuesday, December 18, 2012 5:16 AM
Wednesday, December 5, 2012 5:06 PM -
Integrated authentication will prevent you from doing this client side. You need to create a proxy IOrganizationService under a different User Id. The following code can be used in a Plug-in or custom workflow activity to generate an IOrganizationService under the System Admin user. You will use the IOrganizationService generated to execute your transaction:
public IOrganizationService GetSystemAdminProxy() { Organization org = _svc.Retrieve(Organization.EntityLogicalName, _context.OrganizationId, new ColumnSet("systemuserid")).ToEntity<Organization>(); IOrganizationService svcProxy = (IOrganizationService)_factory.CreateOrganizationService((Guid)org.SystemUserId); return svcProxy; }
-JayB- Proposed as answer by JLattimerMVP, Moderator Wednesday, December 5, 2012 6:13 PM
- Marked as answer by JLattimerMVP, Moderator Tuesday, December 18, 2012 5:16 AM
Wednesday, December 5, 2012 5:18 PM
All replies
-
Hi,
As far as I know there is no possibility to execute JScript-statements against the crm server with other permissions as the ones of the current user.
To solve your problem you can use a plugin and run this plugin as another user who has more permissions.
Best regards,
AndreasAndreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- Proposed as answer by JLattimerMVP, Moderator Wednesday, December 5, 2012 6:13 PM
- Marked as answer by JLattimerMVP, Moderator Tuesday, December 18, 2012 5:16 AM
Wednesday, December 5, 2012 5:06 PM -
Integrated authentication will prevent you from doing this client side. You need to create a proxy IOrganizationService under a different User Id. The following code can be used in a Plug-in or custom workflow activity to generate an IOrganizationService under the System Admin user. You will use the IOrganizationService generated to execute your transaction:
public IOrganizationService GetSystemAdminProxy() { Organization org = _svc.Retrieve(Organization.EntityLogicalName, _context.OrganizationId, new ColumnSet("systemuserid")).ToEntity<Organization>(); IOrganizationService svcProxy = (IOrganizationService)_factory.CreateOrganizationService((Guid)org.SystemUserId); return svcProxy; }
-JayB- Proposed as answer by JLattimerMVP, Moderator Wednesday, December 5, 2012 6:13 PM
- Marked as answer by JLattimerMVP, Moderator Tuesday, December 18, 2012 5:16 AM
Wednesday, December 5, 2012 5:18 PM