Fault exception handling RRS feed

  • Question

  • Hello, 

    My application as been throwing an exception " Policy prohibits the request from completing" when aim trying to update a person object. 
    How can i handle this exception, could you please help me ?

    Here is my code:

    public string ModifyPersonName(string Name)
                // This  shows the basic steps to modify a resource.
                using (DefaultClient client = new DefaultClient())
                    string filterName = "/Person[AccountName='" + HttpContext.Current.User.Identity.Name.Split('\\')[1].ToString() + "']";
                    System.Security.Principal.WindowsImpersonationContext ctx = null;
                    ctx = ((System.Security.Principal.WindowsIdentity)HttpContext.Current.User.Identity).Impersonate();

                    //set credentials and refresh schema

                    // get the person(s) object(s) to modify
                    foreach (RmPerson person in client.Enumerate(filterName))
                        // create the object to track changes to the resource
                        RmResourceChanges changes = new RmResourceChanges(person);
                            // change something in the resource
                            person.DisplayName = Name.ToString();
                            // modify the resource on the server
                            // the operation succeeded: accept the changes.
                            // NOTE: after calling AcceptChanges the RmResourceChanges 
                            // object does not contain any more changes to propagate to
                            // the server.
                        catch (FaultException<AuthorizationRequiredFault> ex)
                            // approval required
                            return " Requested Submitted, approval is pending";

                            string jsonResponse = new JavaScriptSerializer().Serialize(ex.Message);
                            string aposUnicode = "\\u0027";
                            return jsonResponse.Replace(aposUnicode, "'"); ;
                        catch (FaultException<PermissionDeniedFault>)
                            return "Permissions Denied";
                        catch (Exception ex)
                            return ex.Message;
                            // an error occurred, so the resource was not modified; 
                            // rollback the changes.
                    return "Requested Submitted, Auto approved";

    Monday, April 27, 2015 9:51 PM

All replies

  • In the FIM portal search requests and look for the request. See what happened, which policies applied, and who the request ran as. That way you can see if your impersonation worked.

    David Lundell, Get your copy of FIM Best Practices Volume 1

    Wednesday, April 29, 2015 1:44 AM