Removing User Policy




Go back to index

How to remove policy for a user in web application


Following code block explains how to programmatically remove an user policy in a web application.

      using System;
      using SPTool.Library;
      using System.Collections;
      
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTWebApplication webApplication = new SPTWebApplication("http://sptool/");

                  // Delete Policy for User
                  SPTReturn returnObj = webApplication.RemovePolicyForUser(@"Domain/TestUser", new ArrayList(new string[] { "SPTool Permissions" }));

                  // Check the status of deleting policy
                  if (returnObj.State == SPTState.Success)
                  {
                      // Deleting Policy Successful
                  }
                  else
                  {
                      // Deleting Policy Failed
                  }
              }
          }
      }


Go back to index