<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>alinolaru.com &#187; moss</title>
	<atom:link href="http://www.alinolaru.com/tag/moss/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alinolaru.com</link>
	<description>Challenge the possibilities!</description>
	<lastBuildDate>Mon, 26 Oct 2009 12:27:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Soap Server Error When Trying To Edit Pages In SharePoint Designer</title>
		<link>http://www.alinolaru.com/2009/10/soap-server-error-when-trying-to-edit-pages-in-sharepoint-designer/</link>
		<comments>http://www.alinolaru.com/2009/10/soap-server-error-when-trying-to-edit-pages-in-sharepoint-designer/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 21:10:00 +0000</pubDate>
		<dc:creator>Alin Olaru</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[spd]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://www.alinolaru.com/?p=145</guid>
		<description><![CDATA[Another interesting happening from the awesome world of SharePoint errors and (i dare say) bugs is this weird error you can sometimes get when you try to open a page in the SharePoint Designer, particularly a WebPart page, even the Default.aspx. Starting from the beginning, I should remind you how SharePoint web part pages work. [...]]]></description>
			<content:encoded><![CDATA[<p>Another interesting happening from the awesome world of SharePoint errors and (i dare say) bugs is this weird error you can sometimes get when you try to open a page in the SharePoint Designer, particularly a WebPart page, even the Default.aspx. Starting from the beginning, I should remind you how SharePoint web part pages work. The fact of the matter is that while you can edit them and their code in SharePoint Designer, adding/closing/deleting web parts from within the browser interface also modifies the page&#8217;s code.<span id="more-145"></span></p>
<p>What SharePoint won&#8217;t tell you and you have to find out for yourself is that whenever you &#8220;Close&#8221; a WebPart that contains an error it actually remains on the page, even though it&#8217;s hidden. Thus, the page will render fine in the browser and you can be happy to have created an error-free page. But what if you later decide to manually make some changes to the page&#8217;s code? You will soon find out that trying to open it in the SharePoint Designer will cause an error to appear, which tells you that the operation has failed and that the page is unsafe. The error  message is something like the following:</p>
<blockquote>
<p style="text-align: left;">soap:ServerServer was unable to process request. &#8212;&gt; A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered as safe on this site. You may not be able to open this page in an HTML editor that is compatible with Microsoft Windows SharePoint Services, such as Microsoft Office SharePoint Designer. To fix this page, contact the site administrator to have the Web Part or Web Form Control configured as safe.</p>
</blockquote>
<p style="text-align: left;">I have tried to figure out what is wrong and did some searching around and came to the conclusion above. You should use &#8220;Delete&#8221; to eliminate faulty, unsafe or not-working web parts. If you have been using the former method and are stuck with a page that is apparently uneditable in SharePoint Deisgner, try accessing your faulty page with a contents=1 variable, for example: http://my-example.com/Default.aspx?contents=1. This will load the page in maintenance mode and you will be able to spot and remove the errors and unsafe controls. Be wary that you might notice a good series of &#8220;Error&#8221; web parts. Those should be the first ones to go after.</p>
<p style="text-align: left;">After doing the above, try re-opening the page in SPD. You fill find that now you will be able to successfully edit the source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alinolaru.com/2009/10/soap-server-error-when-trying-to-edit-pages-in-sharepoint-designer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Correct Way Of Updating List Items in SharePoint</title>
		<link>http://www.alinolaru.com/2009/09/the-correct-way-of-updating-list-items-in-sharepoint/</link>
		<comments>http://www.alinolaru.com/2009/09/the-correct-way-of-updating-list-items-in-sharepoint/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 14:23:52 +0000</pubDate>
		<dc:creator>Alin Olaru</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[edit list items]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://www.alinolaru.com/?p=122</guid>
		<description><![CDATA[Many times you will need to manipulate data within a list in your custom SharePoint page or web part. Out of these times, you might also need to edit the data in that list like in, for example, a user profile edit page or a contact edit page. Some might say that this is a [...]]]></description>
			<content:encoded><![CDATA[<p>Many times you will need to manipulate data within a list in your custom SharePoint page or web part. Out of these times, you might also need to edit the data in that list like in, for example, a user profile edit page or a contact edit page. Some might say that this is a piece of cake, just assign the required value to the SPListItem and be on your way. Alas, this is not the case, since if you only do this you might realize that the data you need hasn&#8217;t been updated in the database. Though it cannot be called a major inconvenience with the SharePoint object model, it is a bit disorienting and might be a bit of a hassle until you get the actual hang of it.<span id="more-122"></span></p>
<p>Thus, the following would be an example of redundant code that would provide no actual functionality:</p>
<blockquote><p style="color: #ff6600;">SPList uList = SPContext.Current.Site.RootWeb.Lists["Contact Info"];<br />
string fName = &#8243;John&#8243;;<br />
string lName = &#8243;Doe&#8243;;<br />
string cPhone = &#8243;555-123456&#8243;;</p>
<p style="color: #ff6600;">for (int i=0;i&lt;uList.Items.Count;i++)<br />
{<br />
&nbsp;&nbsp;&nbsp;uList.Items[i]["First Name"] = fName;<br />
&nbsp;&nbsp;&nbsp;uList.Items[i]["Last Name"] = lName;<br />
&nbsp;&nbsp;&nbsp;uList.Items[i]["Phone"] = cPhone;<br />
}</p>
</blockquote>
<p>The code above doesn&#8217;t actually do anything, because even though we assign the values we need to the fields and entries we need we don&#8217;t tell SharePoint to also update this into its database. The correct way to do this is to call the Update() method after assigning the values to the fields. But in doing this, we also cannot use the uList.Items[index][fieldName] object, because we cannot use the method with it. Instead, we create a separate SPListItem object and assign the respective entry from the list to that object, like in the example below.</p>
<blockquote><p>SPList uList = SPContext.Current.Site.RootWeb.Lists["Contact Info"];<br />
string fName = &#8243;John&#8243;;<br />
string lName = &#8243;Doe&#8243;;<br />
string cPhone = &#8243;555-123456&#8243;;</p>
<p>for (int i=0;i&lt;uList.Items.Count;i++)<br />
{<br />
&nbsp;&nbsp;&nbsp;SPListItem theContact = uList.Items[i];</p>
<p>&nbsp;&nbsp;&nbsp;theContact["First Name"] = fName;<br />
&nbsp;&nbsp;&nbsp;theContact["Last Name"] = lName;<br />
&nbsp;&nbsp;&nbsp;theContact["Phone"] = cPhone;</p>
<p>&nbsp;&nbsp;&nbsp;theContact.Update();<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.alinolaru.com/2009/09/the-correct-way-of-updating-list-items-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get SharePoint User Information In C#</title>
		<link>http://www.alinolaru.com/2009/08/get-sharepoint-user-information-in-c/</link>
		<comments>http://www.alinolaru.com/2009/08/get-sharepoint-user-information-in-c/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 20:23:32 +0000</pubDate>
		<dc:creator>Alin Olaru</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[moss]]></category>
		<category><![CDATA[user information list]]></category>
		<category><![CDATA[wss]]></category>

		<guid isPermaLink="false">http://www.alinolaru.com/?p=12</guid>
		<description><![CDATA[I am posting this tutorial because it seems there are very few articles on the net that actually present you with a practical way of retrieving SharePoint user information in C#, for example to display in a WebPart. Most of these articles describe the method of programatically achieving this for Microsoft SharePoint Server 2007 (MOSS), [...]]]></description>
			<content:encoded><![CDATA[<p>I am posting this tutorial because it seems there are very few articles on the net that actually present you with a practical way of retrieving SharePoint user information in C#, for example to display in a WebPart. Most of these articles describe the method of programatically achieving this for Microsoft SharePoint Server 2007 (MOSS), but in Windows SharePoint Services (WSS) this bit is more tricky. Mainly because WSS keep only limited user info and also because it uses a hidden list to store that information.<span id="more-12"></span></p>
<p>I&#8217;ll go over the procedures for both MOSS and WSS for comparison.</p>
<h3>Microsoft SharePoint Server 2007</h3>
<p>For MOSS, the process is fairly straightforward. The following code listing should get you going.</p>
<blockquote><p>//These are the libraries you need to reference and include in your WebPart class or your SharePoint page<br />
using Microsoft.Office.Server.UserProfiles;<br />
using Microsoft.SharePoint.Portal.Topology;<br />
using Microsoft.Office.Server;</p>
<p>//This is the actual code for retrieving user info in MOSS, include it where needed<br />
ServerContext context = ServerContext.GetContext(SPContext.Current.Site);<br />
UserProfileManager profileManager = new UserProfileManager(context);<br />
Microsoft.Office.Server.UserProfiles.PropertyCollection props = profileManager.Properties;</p>
<p>foreach (Property prop in props)<br />
{<br />
&nbsp;&nbsp;&nbsp;Response.Write(prop.Name + &#8220;&lt;br/&gt;&#8221;);<br />
}</p>
<p>ServerContext context2 = ServerContext.GetContext(SPContext.Current.Site);<br />
UserProfileManager profileManager2 = new UserProfileManager(context2);<br />
foreach (UserProfile profile in profileManager2)<br />
{<br />
&nbsp;&nbsp;&nbsp;UserProfileValueCollection FirstNameProp = profile["AccountName"];<br />
&nbsp;&nbsp;&nbsp;Response.Write(FirstNameProp[0].ToString() + &#8220;&lt;br/&gt;&#8221;);<br />
}</p></blockquote>
<h3>Windows SharePoint Services 3.0</h3>
<p>For WSS it becomes a bit more tricky. That is because we lack classes the libraries in the example above. WSS stores only partial user info by default, while additional fields and such must be manually added to the list by the website developer/administrator. Apart from that purely administrational issue, the code is also a tad more difficult to implement. Basically, what we do is get this hidden user list and access it not through specialised classes, but like any other normal list and parse through it&#8217;s entries and fields. A code example would be the one below which is used to retrieve the user info for the currently logged user.</p>
<blockquote><p>//These are the libraries you need to reference and include in your WebPart class<br />
using System.Web.UI.WebControls.WebParts;<br />
using Microsoft.SharePoint;<br />
using Microsoft.SharePoint.Administration;</p>
<p>//This assumes you want the WebPart to display basic info about your currently logged in user<br />
protected override void CreateChildControls()<br />
{<br />
&nbsp;&nbsp;&nbsp;base.CreateChildControls();</p>
<p>&nbsp;&nbsp;&nbsp;try<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPSecurity.RunWithElevatedPrivileges(delegate() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPList uList = SPContext.Current.Site.RootWeb.Lists["User Information List"];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPUser pUser = SPContext.Current.Site.RootWeb.CurrentUser;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int i = FindInList(uList, pUser.ID);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (i != -1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls.Add(new LiteralControl(@&#8221;&lt;strong&gt;Name: &lt;/strong&gt;&#8221; + (string)uList.Items[i]["Name"] + @&#8221;&lt;br /&gt;&#8221;));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls.Add(new LiteralControl(@&#8221;&lt;strong&gt;Job Title: &lt;/strong&gt;&#8221; + (string)uList.Items[i]["Job Title"] + @&#8221;&lt;br /&gt;&#8221;));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls.Add(new LiteralControl(@&#8221;&lt;strong&gt;Department: &lt;/strong&gt;&#8221; + (string)uList.Items[i]["Department"] + @&#8221;&lt;br /&gt;&#8221;));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls.Add(new LiteralControl(@&#8221;Could not retrieve user info!&#8221;));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});<br />
&nbsp;&nbsp;&nbsp;} catch (Exception ex)<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls.Add(new LiteralControl(@&#8221;&lt;strong&gt;ERROR:&lt;/strong&gt;&lt;br /&gt;&#8221; + ex.Message + &#8221; at &#8221; + ex.Source + &#8220;&lt;br /&gt;Stack Trace:&lt;br /&gt;&#8221; + ex.StackTrace));<br />
&nbsp;&nbsp;&nbsp;}<br />
}</p>
<p>protected int FindInList(SPList uList, int userID)<br />
{<br />
&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt; uList.Items.Count &#8211; 1; i++)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((int)uList.Items[i]["ID"] == userID)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return i;</p>
<p>&nbsp;&nbsp;&nbsp;return -1;<br />
}</p></blockquote>
<p>Let&#8217;s look a bit at the listing and see what do we actually do. First, we use the SPSecurity class to run the code with elevated privileges because the <em>User Information List</em> list is hidden and is not normally visible to normal user, only to those with Admin privileges. Next we set up the uList and pUser objects, the first of which holds the user info list, while the second is a sPUser object holding the basic data for the currently logged in user. I use the FindInList method to retrieve the id of the currently logged in user within the uList.Items collection. Then we verify whether the user was found in the list. If it is there, we show his name, job title and department, else we show a simple message stating we cannot retrieve user info.</p>
<h3>Conclusion</h3>
<p>Windows SharePoint Services uses a more rudimentary system for providing access to its user base to the common developer. MOSS on the other hand has specialized classes for this, making it easier to access the data in a timely generic fashion through the use of the Property object. Well, we&#8217;ll just conclude that this is just one of the many omissions in WSS compared to MOSS, making you curse your days for choosing the <em>free</em> path instead of paying a premium for the full service.  I will return with more basic tutorials covering other aspects of SharePoint Services as I progress in my study and use of this piece of software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alinolaru.com/2009/08/get-sharepoint-user-information-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
