<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Madhawa Learns To Blog : C#, Java</title>
        <link>http://geekswithblogs.net/madhawa/Default.aspx</link>
        <description>.net, c#, java,sql, OOAD and more mad memory dumps...</description>
        <language>en-US</language>
        <copyright>Madhawa Karunaratne</copyright>
        <managingEditor>madhawa@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>Madhawa Learns To Blog : C#, Java</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/madhawa/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Use string values in Enum (c#)</title>
            <category>.net</category>
            <category>.net 3.0</category>
            <link>http://geekswithblogs.net/madhawa/archive/2011/09/07/146786.aspx</link>
            <description>&lt;p&gt;Very useful article by Wayne Hartman.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.waynehartman.com/articles/84.aspx"&gt;http://blog.waynehartman.com/articles/84.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/146786.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2011/09/07/146786.aspx</guid>
            <pubDate>Wed, 07 Sep 2011 14:30:27 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/146786.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2011/09/07/146786.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/146786.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/146786.aspx</trackback:ping>
        </item>
        <item>
            <title>Enable Content Approval on a Custom SharePoint list using the list definition</title>
            <category>MOSS</category>
            <link>http://geekswithblogs.net/madhawa/archive/2011/08/24/146652.aspx</link>
            <description>&lt;p&gt;Yesterday I realized that non of my custom lists enforce content approval by default. That really worried me as 90% of the data we display in the web site which I'm working on are coming from custom lists.&lt;/p&gt;
&lt;p&gt;Enabling this manually is a piece of cake but I wanted to include this in the list definition.&lt;/p&gt;
&lt;p&gt;After some research and testing I found out that there are 2 places you have to configure.&lt;/p&gt;
&lt;p&gt;You have to set &lt;strong&gt;ModeratedList="TRUE"&lt;/strong&gt; for &lt;em&gt;List element &lt;/em&gt;and &lt;strong&gt;EnableModeration="True"&lt;/strong&gt; for &lt;em&gt;ListTemplate element &lt;/em&gt;in your schema files.&lt;/p&gt;
&lt;p&gt;Remember this works only for new lists you are creating from these definitions but wouldn't affect lists which already exist.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/146652.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2011/08/24/146652.aspx</guid>
            <pubDate>Wed, 24 Aug 2011 12:57:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/146652.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2011/08/24/146652.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/146652.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/146652.aspx</trackback:ping>
        </item>
        <item>
            <title>GetUserListSchema(): Failed to get the list schema XML for feature</title>
            <category>.net</category>
            <category>MOSS</category>
            <link>http://geekswithblogs.net/madhawa/archive/2011/06/15/145875.aspx</link>
            <description>&lt;p&gt;These days I'm working on a CMS solution and I had all my list definitions and list instances in one feature, so everything was working fine.&lt;/p&gt;
&lt;p&gt;But its not ideal as each time I change the list definitions I have to de-activate and re-activate the whole feature. And each time I do that the default data I have defined in list definitions are duplicated.&lt;/p&gt;
&lt;p&gt;So I created another feature for list instances but its giving the following error when trying to activate.&lt;/p&gt;
&lt;p&gt;"GetUserListSchema(): Failed to get the list schema XML for feature"&lt;/p&gt;
&lt;p&gt;Problem was as I was using the element files from the old feature I hadn't defined the "FeatureId" in the "ListInstance" schema. So remember if you have list instances in a different feature than your List definitions, you gotta give the "FeatureId" in the "ListInstance" schema. Its optional if you have all in one feature.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/145875.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2011/06/15/145875.aspx</guid>
            <pubDate>Wed, 15 Jun 2011 17:15:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/145875.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2011/06/15/145875.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/145875.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/145875.aspx</trackback:ping>
        </item>
        <item>
            <title> Kill w3wp.exe and all it's child process</title>
            <category>.net</category>
            <category>misc</category>
            <link>http://geekswithblogs.net/madhawa/archive/2010/06/23/140562.aspx</link>
            <description>&lt;p&gt;Going over all the w3wp processes in task manager is frustrating if you wanna do this frequently :). So here it is.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;taskkill /F /IM w3wp.exe /T&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Works in the command line and PowerShell as well.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/140562.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2010/06/23/140562.aspx</guid>
            <pubDate>Wed, 23 Jun 2010 08:53:46 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/140562.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2010/06/23/140562.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/140562.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/140562.aspx</trackback:ping>
        </item>
        <item>
            <title>Add Permission Level to a Sharepoint user group collection</title>
            <category>.net 3.0</category>
            <category>.net</category>
            <category>MOSS</category>
            <category>MOSS Object Model</category>
            <link>http://geekswithblogs.net/madhawa/archive/2009/08/17/134159.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// &lt;span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 16px 'Times New Roman'; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"&gt;&lt;span class="Apple-style-span" style="FONT-SIZE: 13px; FONT-FAMILY: Arial; WHITE-SPACE: pre"&gt;Add Permission Level to a Sharepoint user group collection&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;font face="Arial"&gt;        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name="spWeb"&amp;gt;The sp web.&amp;lt;/param&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name="permissionName"&amp;gt;Name of the permission.&amp;lt;/param&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name="groupCollection"&amp;gt;The group collection.&amp;lt;/param&amp;gt;&lt;br /&gt;
        public static void AddPermissionsToGroupCollection(SPWeb spWeb, string permissionName, string[] groupCollection)&lt;br /&gt;
        {&lt;br /&gt;
            SPSecurity.RunWithElevatedPrivileges(delegate&lt;br /&gt;
            {&lt;br /&gt;
                try&lt;br /&gt;
                {&lt;br /&gt;
                    //Allow updating of some sharepoint lists, (here spUsers, spGroups etc...)&lt;br /&gt;
                    spWeb.AllowUnsafeUpdates = true;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                    SPRoleDefinition roleDefinition = spWeb.RoleDefinitions[permissionName];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                    foreach (string group in groupCollection)&lt;br /&gt;
                    {&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                        SPGroup spGroup = spWeb.Groups[group];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                        SPRoleAssignment roleAssignment = new SPRoleAssignment(spGroup);&lt;br /&gt;
                        SPRoleDefinitionBindingCollection roleDefBindings = roleAssignment.RoleDefinitionBindings;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                        roleDefBindings.Add(roleDefinition);&lt;br /&gt;
                        spWeb.RoleAssignments.Add(roleAssignment);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                        roleDefinition.Update();&lt;br /&gt;
                    }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                }&lt;br /&gt;
                catch (Exception ex)&lt;br /&gt;
                {&lt;br /&gt;
                    //Error handling logic should go here&lt;br /&gt;
                    throw ex;&lt;br /&gt;
                }&lt;br /&gt;
                finally&lt;br /&gt;
                {&lt;br /&gt;
                    spWeb.AllowUnsafeUpdates = false;&lt;br /&gt;
                }&lt;/font&gt;&lt;font face="Arial"&gt;&lt;br /&gt;
            });&lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Ok this is it. &lt;/p&gt;
&lt;p&gt;Well... I called above method from "&lt;font face="Arial"&gt;FeatureActivated" &lt;/font&gt;event of a feature. For "&lt;font face="Arial"&gt;FeatureDeactivating" &lt;/font&gt;event I tried to achieve the contrary to this, delete a permission level from a user group. But didn't succeed. :( &lt;/p&gt;
&lt;p&gt;If you have any idea pls let us know.Thanks in advance.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/134159.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2009/08/17/134159.aspx</guid>
            <pubDate>Tue, 18 Aug 2009 04:06:21 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/134159.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2009/08/17/134159.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/134159.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/134159.aspx</trackback:ping>
        </item>
        <item>
            <title>Get value collection of a SharePoint Choice Field</title>
            <category>.net</category>
            <category>.net 3.0</category>
            <category>MOSS</category>
            <category>MOSS Object Model</category>
            <link>http://geekswithblogs.net/madhawa/archive/2009/08/01/133849.aspx</link>
            <description>&lt;p&gt;&lt;font face=""&gt; public static List&amp;lt;string&amp;gt; GetChoiceFieldValues(string listName,string fieldName, string siteCollection, string webSite)&lt;br /&gt;
        {&lt;br /&gt;
            List&amp;lt;string&amp;gt; fieldList;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;            SPSite spSite = null;&lt;br /&gt;
            SPWeb spWeb = null;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;            try&lt;br /&gt;
            {&lt;br /&gt;
                if (siteCollection != null)&lt;br /&gt;
                    spSite = new SPSite(siteCollection);&lt;br /&gt;
                else&lt;br /&gt;
                    spSite = SPContext.Current.Site;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                if (webSite != null)&lt;br /&gt;
                    spWeb = spSite.OpenWeb(webSite);&lt;br /&gt;
                else&lt;br /&gt;
                    spWeb = spSite.OpenWeb();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                SPList spList = spWeb.Lists[listName];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                SPFieldChoice field = (SPFieldChoice)spList.Fields[fieldName];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                fieldList = new List&amp;lt;string&amp;gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                foreach (string str in field.Choices)&lt;br /&gt;
                {&lt;br /&gt;
                    fieldList.Add(str);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            catch (Exception ex)&lt;br /&gt;
            {&lt;br /&gt;
                LogException(ex);&lt;br /&gt;
                throw;&lt;br /&gt;
            }&lt;br /&gt;
            finally&lt;br /&gt;
            {&lt;br /&gt;
                if(spWeb != null)&lt;br /&gt;
                    spWeb.Close();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;                if(spSite != null)&lt;br /&gt;
                    spSite.Close();&lt;br /&gt;
            }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;            return fieldList;&lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/133849.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2009/08/01/133849.aspx</guid>
            <pubDate>Sat, 01 Aug 2009 09:01:40 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/133849.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2009/08/01/133849.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/133849.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/133849.aspx</trackback:ping>
        </item>
        <item>
            <title>Renaming a Report Server Computer and next....</title>
            <link>http://geekswithblogs.net/madhawa/archive/2009/06/29/133126.aspx</link>
            <description>&lt;p&gt;&lt;font face=""&gt;You know what happens when we change the name of a SharePoint server right? It simply won’t work again unless you run the SharePoint Server configuration wizard.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;So what would happen if you do the same for the SSRS (SQL server reporting services) server? Some say you might not be able to connect to the reporting services again. I changed my reporting server’s name and still was able to create reports and do some other things. But clearly there were some problems. I tried to get support from my colleagues who were already familiar with SSRS but with no luck. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;After some googling I found below link looks promising. But alas… it didn’t resolve my prob. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms345235(SQL.90).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms345235(SQL.90).aspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;If I point my problem clearly, when I try to do &lt;strong&gt;“Configure report server - &amp;gt; Initialization”&lt;/strong&gt; it shows me old machine name (name before I rename it) which will causes lots of problem in future. (That was according to my colleagues and I don’t know what those problems would be as this is the first time I’m gonna use SSRS)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="http://farm4.static.flickr.com/3401/3671777983_8e9de7a38b_o.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;Then I tried to create a new reporting server database through &lt;strong&gt;“Configure report server - &amp;gt; Data Setup”.&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=""&gt;Guess what? It worked and saved my day!&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/133126.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2009/06/29/133126.aspx</guid>
            <pubDate>Mon, 29 Jun 2009 17:29:26 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/133126.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2009/06/29/133126.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/133126.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/133126.aspx</trackback:ping>
        </item>
        <item>
            <title>Errors "Microsoft .NET Framework 3.5 installation has failed. SQL 2008 Setup requires .NET 3.5 to be installed." and  "This server version is not supported. Only servers up to Microsoft SQL Server 2005 are supported."</title>
            <category>.net</category>
            <link>http://geekswithblogs.net/madhawa/archive/2009/01/22/128897.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;Today I had to work on a project which uses VS2008 and SQL Server 2008. I haven't used SQL2008 but had used VS2008 a little bit. When I tried to install SQL2008 (Developer edition) got this strange error which says "Microsoft .NET Framework 3.5 installation has failed. SQL 2008 Setup requires .NET 3.5 to be installed."&lt;br /&gt;
&lt;br /&gt;
Strange thing is I had installed .NET 3.5 in the VPC upfront. Actually you are installing .NET 3.5 when you install VS2008 right?&lt;br /&gt;
&lt;br /&gt;
Anyway I tried to resolve this using,&lt;br /&gt;
&lt;br /&gt;
1. Uninstall .NET 3.5 and try install SQL 2008 (SQL 2008 setup comming with .NET 3.5 installation)&lt;br /&gt;
&lt;br /&gt;
2. Reinstall .NET 3.5 and install SQL 2008&lt;br /&gt;
&lt;br /&gt;
3. Reinstall .NET 3.5, service pack and install SQL 2008&lt;br /&gt;
&lt;br /&gt;
Yes... I failed. I can't remember what other things I tried. :)&lt;br /&gt;
&lt;br /&gt;
So then I went for other possible option, that is to connect to an existing SQL2008 server through VS2008. Then I got this damn error message.&lt;br /&gt;
&lt;br /&gt;
 "This server version is not supported. Only servers up to Microsoft SQL Server 2005 are supported.".&lt;br /&gt;
&lt;br /&gt;
But fortunately this time I got the resolution. You had to install &amp;lt;a href="http://download.microsoft.com/download/6/7/0/670ce765-4c9b-4620-902f-b9fc9a7c3c2d/vs90-kb945855.exe"&amp;gt;vs90-kb945855.exe&amp;lt;/a&amp;gt;. Then you can connect to SQL2008 from VS2008. &lt;br /&gt;
&lt;br /&gt;
But still I didn't get an answer for my first prob. If anyone knows the answer pls drop the solution here. Thanks in advance.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;/font&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/128897.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2009/01/22/128897.aspx</guid>
            <pubDate>Fri, 23 Jan 2009 03:21:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/128897.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2009/01/22/128897.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/128897.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/128897.aspx</trackback:ping>
        </item>
        <item>
            <title>Add a user programmatically to a User Group in SharePoint</title>
            <category>.net</category>
            <category>MOSS</category>
            <category>MOSS Object Model</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/11/18/127171.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Add a user to a Sharepoint group&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name="userLoginName"&amp;gt;Login name of the user to add&amp;lt;/param&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name="userGroupName"&amp;gt;Group name to add&amp;lt;/param&amp;gt;&lt;br /&gt;
        private void AddUserToAGroup(string userLoginName, string userGroupName)&lt;br /&gt;
        {&lt;br /&gt;
            &lt;strong&gt;//Executes this method with Full Control rights even if the user does not otherwise have Full Control&lt;/strong&gt;&lt;br /&gt;
            SPSecurity.RunWithElevatedPrivileges(delegate&lt;br /&gt;
            {&lt;br /&gt;
               &lt;strong&gt; //Don't use context to create the spSite object since it won't create the object with elevated privileges but with the privileges of the user who execute the this code, which may casues an exception&lt;br /&gt;
&lt;/strong&gt;                using (SPSite spSite = new SPSite(Page.Request.Url.ToString()))&lt;br /&gt;
                {&lt;br /&gt;
                    using (SPWeb spWeb = spSite.OpenWeb())&lt;br /&gt;
                    {&lt;br /&gt;
                        try&lt;br /&gt;
                        {&lt;br /&gt;
                          &lt;strong&gt;  //Allow updating of some sharepoint lists, (here spUsers, spGroups etc...)&lt;br /&gt;
&lt;/strong&gt;                            spWeb.AllowUnsafeUpdates = true;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                            SPUser spUser = spWeb.EnsureUser(userLoginName);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                            if (spUser != null)&lt;br /&gt;
                            {&lt;br /&gt;
                                SPGroup spGroup = spWeb.Groups[userGroupName];&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;                                if (spGroup != null)&lt;br /&gt;
                                    spGroup.AddUser(spUser);&lt;br /&gt;
                            }&lt;br /&gt;
                        }&lt;br /&gt;
                        catch (Exception ex)&lt;br /&gt;
                        {&lt;br /&gt;
                            //Error handling logic should go here&lt;br /&gt;
                        }&lt;br /&gt;
                        finally&lt;br /&gt;
                        {&lt;br /&gt;
                            spWeb.AllowUnsafeUpdates = false;&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;            });&lt;br /&gt;
        }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here in this method you have to set "&lt;font face="Arial"&gt;spWeb.AllowUnsafeUpdates = true" to allow updating some sharepoint lists. &lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/127171.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/11/18/127171.aspx</guid>
            <pubDate>Tue, 18 Nov 2008 12:47:11 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/127171.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/11/18/127171.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/127171.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/127171.aspx</trackback:ping>
        </item>
        <item>
            <title>Understand SharePoint Permissions </title>
            <link>http://geekswithblogs.net/madhawa/archive/2008/11/11/126941.aspx</link>
            <description>&lt;p&gt;Check these really good articles by &lt;a target="_blank" href="http://jamestsai.net"&gt;James Tsai&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a class="taggedlink" href="http://jamestsai.net/Blog/post/Understand-SharePoint-Permissions-Part-1-SPBasePermissions-in-Hex2c-Decimal-and-Binary-The-Basics.aspx"&gt;&lt;span&gt;Understand SharePoint Permissions - Part 1. SPBasePermissions in Hex, Decimal and Binary - The Basics&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jamestsai.net/Blog/post/Understand-SharePoint-Permissions-Part-2-Check-SharePoint-usergroup-permissions-with-Permissions-web-service-and-JavaScript.aspx"&gt;Understand SharePoint Permissions - Part 2. Check SharePoint user/group permissions with Permissions web service and JavaScript&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Thanks Suranja for sending me these links.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/126941.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/11/11/126941.aspx</guid>
            <pubDate>Tue, 11 Nov 2008 17:07:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/126941.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/11/11/126941.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/126941.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/126941.aspx</trackback:ping>
        </item>
        <item>
            <title>Can we deploy a Content Type as a feature with some extended settings like "Workflow settings" and "Information management policy settings"?</title>
            <category>misc</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/09/02/124844.aspx</link>
            <description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;I have a small question for sharepoint experts. :)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Can we deploy a Content Type as a feature with some extended settings like "Workflow settings" and "Information management policy settings"?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;If so please enlighten me on how to do that.&lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/124844.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/09/02/124844.aspx</guid>
            <pubDate>Tue, 02 Sep 2008 11:41:44 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/124844.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/09/02/124844.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/124844.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/124844.aspx</trackback:ping>
        </item>
        <item>
            <title>Connecting to the VPC Console Session Directly from RDP</title>
            <category>misc</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/09/01/124837.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;Type below in the command line replacing &amp;lt;MC name or IP&amp;gt; with the machine name or IP you want to connect. This works with WinXP and Vista.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;strong&gt;mstsc -v:&amp;lt;MC name or IP&amp;gt; /f -console&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;Updated:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;:D There is a easy way. Just type &lt;font face="Arial"&gt;&lt;strong&gt;mstsc /console &lt;/strong&gt;in the command prompt.&lt;/font&gt;&lt;br /&gt;
&lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/124837.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/09/01/124837.aspx</guid>
            <pubDate>Tue, 02 Sep 2008 02:31:17 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/124837.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/09/01/124837.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/124837.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/124837.aspx</trackback:ping>
        </item>
        <item>
            <title>STSDEV: Simple Tools for SharePoint 2007 Development, With different project name support</title>
            <category>.net</category>
            <category>MOSS</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/08/26/124686.aspx</link>
            <description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;font face="Verdana" size="2"&gt;STSDEV is a simple tool for SharePoint developers. It helps you to create SharePoint projects (with solutions precisely) and deploy templates and components into the SharePoint 2007 platform.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;a href="http://www.codeplex.com/stsdev"&gt;&lt;font face="Verdana" size="2"&gt;http://www.codeplex.com/stsdev&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;font face="Verdana" size="2"&gt;This tool creates project and solution in same name and in the same folder. We all know we never put the solution and project files in the same folder and never use same name for the solution and the project. Unfortunately we didn’t find a way of changing those and use the tool after since it gives errors. I found a very easy way of tweaking that from changing small line in the source code or changing a line in the generated .target file. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;font face="Verdana" size="2"&gt;And furthermore I have changed the tool to support for supplying a different project name when creating a solution and now we are using it in our SharePoint project. &lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;font face="Verdana" size="2"&gt;BTW I'll explain how to tweak the tool to use separate source folder for project by a small change in the source code in next post. Until then play with the tool and have some fun.&lt;img alt="" src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/regular_smile.gif" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;font face="Verdana" size="2"&gt;If you want that version of the tool with source code please &lt;/font&gt;&lt;a href="mailto:madhawa@gmail.com?subject=STSDEV%20with%20project%20name%20support"&gt;&lt;font face="Verdana" size="2"&gt;email me&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt" align="justify"&gt;&lt;span style="TEXT-TRANSFORM: uppercase"&gt;&lt;o:p&gt;&lt;font face="Verdana" size="2"&gt; &lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/124686.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/08/26/124686.aspx</guid>
            <pubDate>Tue, 26 Aug 2008 15:39:17 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/124686.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/08/26/124686.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/124686.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/124686.aspx</trackback:ping>
        </item>
        <item>
            <title>Effective Error handling in SQL Server 2005</title>
            <category>.net</category>
            <category>Java</category>
            <category>misc</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/08/25/124661.aspx</link>
            <description>&lt;p align="justify"&gt;&lt;font face="Verdana" size="2"&gt;One of the main things you should consider if you believe in good coding is error or exception handling. When it come to programming languages, now all popular object oriented languages have try, catch method to handle an exception.&lt;br /&gt;
&lt;br /&gt;
We can put our code (which might gives errors or exceptions) inside the try block and error handling code in the catch block. This has become the de-facto of error or exception handling now.&lt;br /&gt;
But when it comes to T-SQL we hadn’t got that luxury. Error handling in T-SQL was always tedious and tricky job. Most of the time we used not to handle the error at the T-SQL level but handling it in the upper most level. (data access layer or business layer, handling database errors in business layer is a totally wrong practice)&lt;br /&gt;
&lt;br /&gt;
But now in SQL 2005, 2008 you have proper error handling mechanism just like in modern OO languages. You can use try catch in the stored procedures and functions. Actually I knew that I can use try catch in stored procedures but only today I got to know about a more interesting method we can use.&lt;br /&gt;
&lt;br /&gt;
After catching an error what we can to do was a question for me. If it’s in C# or Java we can log the error and may be throw a customized exception to the next layer. (There are so many options in handling errors)&lt;br /&gt;
Can you remember throw exception in C#? Of cause you know it. :) Well… we can do the same in T-SQL using RAISERROR function. &lt;br /&gt;
&lt;br /&gt;
Using the RAISERROR is as follows,&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;BEGIN TRY&lt;br /&gt;
    -- RAISERROR with severity 11-19 will cause execution to &lt;br /&gt;
    -- jump to the CATCH block.&lt;br /&gt;
    RAISERROR ('Error raised in TRY block.', -- Message text.&lt;br /&gt;
               16, -- Severity.&lt;br /&gt;
               1 -- State.&lt;br /&gt;
               );&lt;br /&gt;
END TRY&lt;br /&gt;
BEGIN CATCH&lt;br /&gt;
    DECLARE @ErrorMessage NVARCHAR(4000);&lt;br /&gt;
    DECLARE @ErrorSeverity INT;&lt;br /&gt;
    DECLARE @ErrorState INT;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;    SELECT &lt;br /&gt;
        @ErrorMessage = ERROR_MESSAGE(),&lt;br /&gt;
        @ErrorSeverity = ERROR_SEVERITY(),&lt;br /&gt;
        @ErrorState = ERROR_STATE();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;    -- Use RAISERROR inside the CATCH block to return error&lt;br /&gt;
    -- information about the original error that caused&lt;br /&gt;
    -- execution to jump to the CATCH block.&lt;br /&gt;
    RAISERROR (@ErrorMessage, -- Message text.&lt;br /&gt;
               @ErrorSeverity, -- Severity.&lt;br /&gt;
               @ErrorState -- State.&lt;br /&gt;
               );&lt;br /&gt;
END CATCH;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Pretty good ha…&lt;br /&gt;
You can follow up this more in &lt;/font&gt;&lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms178592(SQL.90).aspx"&gt;&lt;font face="Verdana" size="2"&gt;MSDN&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt; &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Verdana" size="2"&gt; &lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/124661.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/08/25/124661.aspx</guid>
            <pubDate>Mon, 25 Aug 2008 17:35:47 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/124661.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/08/25/124661.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/124661.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/124661.aspx</trackback:ping>
        </item>
        <item>
            <title>Deploying Sharepoint sites in x64 servers</title>
            <category>misc</category>
            <link>http://geekswithblogs.net/madhawa/archive/2008/01/29/119005.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;Well... After 6 months I’m gonna do it again. I don’t know people who used to visit my blog still are doing that. Anyway will tell ya what happened in last 6 months later. :D&lt;/font&gt;&lt;/p&gt;
&lt;font face="Arial"&gt;
&lt;p&gt;&lt;br /&gt;
Well today I was working on deploying a SharePoint site in 64 bit server. This is the first time I’m putting my hands on x64 bit machines.  If you are used to do or want to do SharePoint deployments and never done that in 64 bit servers just keep in mind below. &lt;/p&gt;
&lt;p&gt;There are 2 programming files folders in 64 bit machines. Normal "programming files" folder for x64 bit programs and "programming files (x86)" for 32 bit programs. So when you are using script files or solutions  (wsp files) for deployment make aware of this. More info will follow…. :)&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;/font&gt; &lt;/p&gt;
&lt;/font&gt; &lt;img src="http://geekswithblogs.net/madhawa/aggbug/119005.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Madhawa Karunaratne</dc:creator>
            <guid>http://geekswithblogs.net/madhawa/archive/2008/01/29/119005.aspx</guid>
            <pubDate>Tue, 29 Jan 2008 06:51:57 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/madhawa/comments/119005.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/madhawa/archive/2008/01/29/119005.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/madhawa/comments/commentRss/119005.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/madhawa/services/trackbacks/119005.aspx</trackback:ping>
        </item>
    </channel>
</rss>
