Please refer to these codes, to Share Records, Share Record only for Read, and Unshare Records.
public void ShareRecord(IOrganizationService service, Entity TargetEntity, Entity TargetShare)
{
//no delete access
GrantAccessRequest grant = new GrantAccessRequest();
grant.Target = new EntityReference(TargetEntity.LogicalName, TargetEntity.Id);
PrincipalAccess principal = new PrincipalAccess();
principal.Principal = new EntityReference(TargetShare.LogicalName, TargetShare.Id);
principal.AccessMask = AccessRights.ReadAccess | AccessRights.AppendAccess | AccessRights.WriteAccess | AccessRights.AppendToAccess | AccessRights.ShareAccess | AccessRights.AssignAccess;
grant.PrincipalAccess = principal;
try
{
GrantAccessResponse grant_response = (GrantAccessResponse)service.Execute(grant);
}
catch (Exception ex)
{
throw ex;
}
}
public void ShareRecordReadOnly(IOrganizationService service, Entity TargetEntity, Entity TargetShare)
{
//no delete access
GrantAccessRequest grant = new GrantAccessRequest();
grant.Target = new EntityReference(TargetEntity.LogicalName, TargetEntity.Id);
PrincipalAccess principal = new PrincipalAccess();
principal.Principal = new EntityReference(TargetShare.LogicalName, TargetShare.Id);
principal.AccessMask = AccessRights.ReadAccess;
grant.PrincipalAccess = principal;
try
{
GrantAccessResponse grant_response = (GrantAccessResponse)service.Execute(grant);
}
catch (Exception ex)
{
throw ex;
}
}
public void UnShareRecord(IOrganizationService service, Entity TargetEntity, Entity TargetShare)
{
//no delete access
ModifyAccessRequest modif = new ModifyAccessRequest(); ;
modif.Target = new EntityReference(TargetEntity.LogicalName, TargetEntity.Id);
PrincipalAccess principal = new PrincipalAccess();
principal.Principal = new EntityReference(TargetShare.LogicalName, TargetShare.Id);
principal.AccessMask = AccessRights.None;
modif.PrincipalAccess = principal;
try
{
ModifyAccessResponse modif_response = (ModifyAccessResponse)service.Execute(modif); ;
}
catch (Exception ex)
{
throw ex;
}
}
Are you looking to make money from your websites/blogs by using popunder advertisments?
ReplyDeleteIf so, have you ever consider using PopAds?