Question

I'm developing custom workflow step for MS CRM 2011.

I wondering is it possible to retrieve NetworkCredentials object representing current user who running this workflow?

Does this information present in CodeActivityContext object?

Here is how Activity definition looks like:

public class CustomActivity : CodeActivity
{
    protected override void Execute(CodeActivityContext context)
    {
    ...
    }
}
Was it helpful?

Solution

Nope. I believe that you would not be able to do that. All the async jobs are done in security context of account that is used for AsyncService login.

OTHER TIPS

you can find who running this workflow If you use these lines:

protected override void Execute(CodeActivityContext context)
{
    IWorkflowContext _Context = context.GetExtension<IWorkflowContext>();
    IOrganizationServiceFactory _IOrganizationServiceFactory = context.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService xrmService = _IOrganizationServiceFactory.CreateOrganizationService(_Context.InitiatingUserId);
}

Something that could help: _Context.InitiatingUserId and you must register your plugin in plugin registration apart from calling user

I think it depends on the type of workflow, you are using. For example I used StateMachine type, where in OnResumeBookmark method could be send object variable, where you can put any structure as interaction with user, who resumed workflow. After resuming you can set some workflow variable and use it as you wish.

Another way is use Workflow arguments of given type, when creating new Workflow instance.

What do you want to do with this credentials?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top