Hi ,
I am trying to write a postcreate callout in CRM 3.0.In that callout i
am trying to give access to an user to read all opportunities.I am
hardcoding both the user and entity with the help of Guid.but it is
not working.
this is the code..
public override void PostCreate(CalloutUserContext userContext,
CalloutEntityContext entityContext, string postImageEntityXml)
{
//Create a CRM Service Object with default credentials
CrmService service = new CrmService();
service.Credentials =
System.Net.CredentialCache.DefaultCredentials;
//assign (hardcode) the Manager
Guid MgrUserId = new Guid("AEA3DEFB-6696-DC11-9427-003048695678");
//Define a SecurityPrincipal Object & assign PrincipalID to
MgrUserId
SecurityPrincipal princi = new SecurityPrincipal();
princi.Type = SecurityPrincipalType.User;
princi.PrincipalId = MgrUserId;
//Set the Access Rights to READ Access
PrincipalAccess princiAccess = new PrincipalAccess();
princiAccess.Principal = princi;
princiAccess.AccessMask = AccessRights.ReadAccess;
//Create a TargetOwnedOpportunity obj & assign the current obj to
it.
TargetOwnedOpportunity tgt = new TargetOwnedOpportunity();
tgt.EntityId = entityContext.InstanceId;
//Grant the Access to the Principal Object (i.e., Manager)
GrantAccessRequest grant = new GrantAccessRequest();
grant.PrincipalAccess = princiAccess;
grant.Target = tgt;
GrantAccessResponse granted =
(GrantAccessResponse)service.Execute(grant);
//base.PostCreate(userContext, entityContext, postImageEntityXml);
}
can anybody hrlp me regarding this..