<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>21apps - inspiring people to change the way they work - Latest Comments in Create Custom Policy programmatically</title><link>http://21apps.disqus.com/</link><description>we help our clients realise SharePoint Business Value</description><atom:link href="https://21apps.disqus.com/create_custom_policy_programmatically/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 27 Oct 2008 08:14:26 -0000</lastBuildDate><item><title>Re: Create Custom Policy programmatically</title><link>http://www.21apps.com/sharepoint/create-custom-policy-programmatically/#comment-6671579</link><description>&lt;p&gt;Ven,&lt;br&gt;The reason is probably due to you not setting any policy bindings, as in the post example:-&lt;/p&gt;&lt;p&gt;policy.PolicyRoleBindings.Add(oWebApplication.PolicyRoles.GetSpecialRole(SPPolicyRoleType.FullControl));&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andrew Woodward</dc:creator><pubDate>Mon, 27 Oct 2008 08:14:26 -0000</pubDate></item><item><title>Re: Create Custom Policy programmatically</title><link>http://www.21apps.com/sharepoint/create-custom-policy-programmatically/#comment-6671578</link><description>&lt;p&gt;Hi,&lt;br&gt;   I am trying to get the users from the "Policy of Web Application" in Central Administration through Object Model&lt;/p&gt;&lt;p&gt;and also trying to add users to the same Policy through object model. I am using the following code to achieve&lt;/p&gt;&lt;p&gt;this. But I am getting an "Object Reference Not Set to an Instance of an Object" exception when I am trying to call&lt;/p&gt;&lt;p&gt;the Update Method of the SPWebApplication object.&lt;br&gt;Please help me. The strange thing happening here is,when I am trying to add the users to the WebApplication policy,&lt;/p&gt;&lt;p&gt;the users are getting added to though the update fails. The next time when I debug the application, I do see the&lt;/p&gt;&lt;p&gt;new users added though the update failed. Moreover, I am not able to see the newly added users in the "Policy For&lt;/p&gt;&lt;p&gt;Web Application" section of the Central Administration. Can anyone please help me out. Here is the code which I am&lt;/p&gt;&lt;p&gt;using to achieve this.&lt;/p&gt;&lt;p&gt;SPFarm farm = SPFarm.Local;   &lt;br&gt;SPWebService service = farm.Services.GetValue("");   &lt;br&gt;foreach(SPWebApplication webApp in service.WebApplications)   &lt;br&gt;{   &lt;br&gt;  if(webApp.Name == "My Web App")   &lt;br&gt;        {   &lt;br&gt;            webApp.ZonePolicies(SPUrlZone.Default).Add("username","displayname");   &lt;br&gt;            webApp.Update();  // I am getting the Object Reference error at this line   &lt;br&gt;        }   &lt;br&gt;}&lt;/p&gt;&lt;p&gt;Please help me ASAP.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ven</dc:creator><pubDate>Sun, 26 Oct 2008 00:39:29 -0000</pubDate></item></channel></rss>