Read all users attributes values in custom workflow
I am following the guide by Ensynch (http://www.ensynch.com/) to get the user attributes when a user gets updated. How can I get ALL user attributes not only the modified ones? As I am very new to FIM, any code examples will help me a lot. Here is the code I am using: RequestType request = this.ReadRequest_Resource1 as RequestType; if (null == request) { throw new InvalidOperationException("current request is null."); } Log(w, "Request [" + request.DisplayName + "] : Type [" + request.Operation + "]"); ReadOnlyCollection<CreateRequestParameter> requestParameters = request.ParseParameters<CreateRequestParameter>(); foreach (CreateRequestParameter requestParameter in requestParameters) { Log(w, " Modified Attributes: " + requestParameter.PropertyName + "= "+ requestParameter.Value); } Krish
June 9th, 2010 1:06am

Hi! If you're supposed to read resources from FIM using workflow I recommend you to use either the ReadResourceActivity for retrieving a single resource or the EnumerateResourcesActivity for being able to get multiple resources. The reason I recommend you to use the activities instead of the WS client (that I'm guessing you're trying to use above) is that the client isn't supported by Microsoft, requires a lot configuration and simply isn't the best way to talk to FIM from workflow. Unfortunately the ReadResourceActivity doesn't have very much documentation yet but is pretty simple to use, simply feed it with the ResourceId Guid for the resource you wish to recieve and a string array of the attributes you wish to get to the SelectionAttributes . The EnumerateResourcesActivity has got some more info around it since it's has been a discussion around how it works and I recommend you to check out the following link to get more info on how it works: http://idmcrisis.com/post/2009/11/16/EnumerateResourcesActivity-the-follow-up.aspx . EnumerateResourcesActivity has a Selection property that works the same way as the SelectionAttributes property for the ReadResourceActivity. I must question your reason to get all attributes, I must say I don't understand why unless you plan to use your workflow for documenting the resources or something similar? Anyway, if you really need to get all attributes you'll have to include them all in the selection properties string array. Henrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2010 7:23am

Henrik, just wanted to confirm that to use ReadResourceActivity inside While loop and Sequence activity you'll have to lookup for parent activity to get proper ActorID (as you noticed for EnumerateResourceActivity). Its really strange that if I would set actorid for readresourceactivity using activity name it will not work. see the code below: (_prepRefV is a code activity inside While loop to resolve all reference values from dictionary) private void _prepRefV(object sender, EventArgs e) { try { SequenceActivity s = (SequenceActivity)((CodeActivity)sender).Parent; ReadResourceActivity r = s.Activities.OfType<ReadResourceActivity>().First(); SequentialWorkflow containingWorkflow = null; if (!SequentialWorkflow.TryGetContainingWorkflow(s, out containingWorkflow)) { throw new InvalidOperationException("Unable to get Containing Workflow"); } // myReadResourceActivity.ActorID = containingWorkflow.ActorId; - doesn't work r.ActorId = containingWorkflow.ActorId; // but this one works r.ResourceId = new Guid(RefWFArguments.ElementAt(0).Value.ToString()); } catch (Exception ex) { throw new InvalidOperationException("Exception:" + ex.Message); } }
June 9th, 2010 10:36am

Of course you can't set ActorID on a ReadResourceActivity with the name "myReadResourceActivity" when the name of your activity is "r". To be honest, you don't have to set ActorID at all because if you'll leave it empty it'll be picked up from the workflow by the activity itself... //Henrik Henrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2010 10:47am

empty (00000-....) ActorID raises "PermissionDeniedException" exception for me and myReadResourceActivity is the real name of ReadResourceActivity object. and studio is happy to compile myReadResourceActivity.ActorID = containingWorkflow.ActorId, but during WF execution it will fail with "Invalid ActorID"
June 9th, 2010 10:56am

:-) That's a mistake you easily make when having an activity within an iterating activity like the while activity. You see, an activity may never be executed more than once within a workflow instance, that's an important aspect in Workflow Foundation. To work around this problem iterating activities instantiates the child activities and uses them as templates and then duplicates them for each iteration. In your case the template ReadResourceActivity is named myReadResourceActivity, this activity is never executed, just duplicated... If you have a closer look at these two lines... SequenceActivity s = (SequenceActivity)((CodeActivity)sender).Parent; ReadResourceActivity r = s.Activities.OfType<ReadResourceActivity>().First(); ...You can see that the SequenceActivity s is the parent of the CodeActivity (sender) and since we get it by the sender we don't get the template activity instead we get the CodeActivity for the current iteration and thereby also the SequenceActivity and ReadResourceActivity that lives in the current iteration. Even thought the name of your ReadResourceActivity is myReadResourceActivity you'll have to use the "r" one since thats the one that will actually be executed, myReadResourceActivity is only a template . I guess you can set ActorID to myReadResourceActivity before the While activity is executed and then the duplicated ReadResourceActivities will get the ActorID automatically but I'm not sure and once again, I believe you don't have to set the ActorID property at all... //HenrikHenrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2010 11:21am

I knew that from your blog. :) The only mistake I made was a suggestion that MyReadResourceActivity will point to the current instance inside while loop. I have to set ResourceID inside the loop anyway, so setting actorID outside the loop will save some processor time but not that much. just checked again - empty actorid will cause 'PermissionExecutionDenied' in my environment. but from the logs I can see that its set to a user submitting a request. setting actorID to the same GUID _INSIDE_ the loop doesn't raise an error. have no idea why - just works this way
June 9th, 2010 12:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics