Convert an SPListItemCollection to an IEnumerable

By adminNo Comments

In one of my last project I make a function to accept an IEnumerable<T> as parameter. I normally used this function with PublishingPageCollection. This collection inherits from QueryBasedCollection<PublishingPage> and so it is a IEnumerable. Unfortunately the SPListItemCollection it is not.

I didn’t want to change my method and I didn’t want to create an overload only for the type of parameters. Then…I remembered that LINQ is my friend :)
You can directly convert an SPListItemCollection. Below an example…hope can help you…

using (SPWeb web = SPContext.Current.Site.OpenWeb("myweb"))
{
       return web.Lists["MyList"].Items.Cast<SPListItem>().Select(item => item);
}
SharePoint

NTFS Volume on Ubuntu 11.10…make it visible to all user

By adminNo Comments

Hello, first of all I’m not a Linux User, meaning I’m not an expert and maybe my post may sound to the “experts” very stupid or obvious.
However, I’ve installed Ubuntu 11.10 on my home laptop and  started to play with it.
In my machine I had a partition (created previously in win7) that I would had liked to use as “data repository”.

If I was the Administrator I could see the disc and all the files inside, but when I logged as a “standard” user the volume was not visible and  I couldn’t open  from media folder, even if I gave to the user the right permission on the folders with chmod

I was really surprised and I felt very stupid…but finally i found the problem.
The disc wasnt’ following the “normal” permission on Linux, because  it was formatted as NTFS. I had to adjust the permissions from the mount options (in fstab if you configured it to mount it automatically).

Below the steps I had followed:

sudo blkid -c /dev/null

and I got this

/dev/sda1: UUID="94C8D394C8D3734A" TYPE="ntfs"
/dev/sda2: UUID="8f5dcee3-7f6d-4f70-975c-10ee27f0df87" TYPE="ext4"
/dev/sda3: LABEL="Data" UUID="8A9E788D9E787393" TYPE="ntfs"
/dev/sda5: UUID="edeb8f21-ac3c-4044-a066-64e160196884" TYPE="swap"

 

My driver was /dev/sda3. I had so to create in MEDIA folder the new reference and then assign in the fstab

 

sudo umount /dev/sda3

After unmounted the driver, I created the folder in the right place:

sudo mkdir /media/Data2

Once opened the Fstab file with the command:

gksu gedit /etc/fstab

I added the following line to the file and saved:

UID=8A9E788D9E787393   /media/Data2  ntfs defaults,gid=46,umask=0000  0  0

The umask=0000 would allow anyone to read/write/execute files on that partition (I could use 2 to turn off write permissions for ‘others’. eg; umask=0002)

Once finished with the file I mounted back the volume and everything was fine…

sudo mount -a

Once again, I’m not a linux “expert”…I just hope that this post can hep someone…

Linux

SharePoint 2010 – Modal Dialog and strange behavior with the dialog.master

By adminNo Comments

In SharePoint 2010 is available the object SP.UI.ModalDialog.You’ll have so the modal dialog windows of SharePoint 2010 available for your application page. That’s cool.

To open the modal dialog you execute the JavaScript code below (you can even add some callback event)

function OpenDialog(strPageURL, delegate, w, h) {
var dialogOptions = SP.UI.$create_DialogOptions();
dialogOptions.url = strPageURL; // URL of the Page
dialogOptions.width = w; // Width of the Dialog
dialogOptions.height = h; // Height of the Dialog
dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, delegate); // Function to capture dialog closed event
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
return false;
}

To do that you have available the Dialog.master master page. It’s a normal master page with specific content place holder.
The problem I had is that if you have for example a flow of pages in the modal dialog, after a redirect, sometime the HEADER of the modal dialog  just disappears. And it does that not everywhere, but just with the Team Site. I don’t know really why, I think it’s something closer to a bug that a feature :) . By the way you can easily solve the problem. Avoid the Dialog.master and, instead, you use a normal ApplicationPage, with the Default.master and you execute the url with the parameter IsDlg=1 in the query string. You’ll have the same behavior of the modal  dialog, but we won’t have the disappeared header. Below you have an image of the problem.

In the first image the header is fine, but then, if you change page you just lose it…

 

 

 

 

 

 

And here the problem

 

 

SharePoint

SharePoint 2010: error crawling People

By adminNo Comments

Today I figured out a funny problem. When you know it’s easy, but I lost an hour to understand what the hell was going on.
In my SharePoint 2010 Farm everything was going fine…I installed and configured the User Profile Synchronization, the MySite was well configured in a specific Web Application. I needed to search people so I went to the Central Administration > Management Application >  Service Application > Search Service Application and start the Full Crawl.

Unfortunately once ended the Full Crawl I had this error on the log:

sps3://SERVERNAME
Error in PortalCrawl Web Service

I started to search and really don’t understand why…In the ULS I found this error:

PortalCrawl.GetSite(): System.NullReferenceException:
Object reference not set to an instance of an object.
at Microsoft.SharePoint.Portal.Search.
PortalCrawl.PortalCrawl.GetSite(_PortalSite& sSite).

and I finally got it. The default site in SharePoint http://SERVERNAME on port 80 must be created and a site collection must be too, otherwise you’ll problem will be not solved. Honestly in my configuration I never use the default web site, because I use personalized DNS, but since today I’ll do always :)
Now my scope “People” is well done:

 

Hope this can help,

M.

 

SharePoint

Ideal configuration for SharePoint 2010 dev environement

By admin1 Comment

In my experience when you develop an application in SharePoint 2010 you should have environment the most close possible to the client configuration. This means that the classical URL http://mysrv:4354 or http://mysrv:3145/sites/mycoll are not the best configuration you can have.

Beside that even to work with a local user is really not the best…you can develop something that locally works like a charm, but when you’ll install into the client farm you’ll be quite surprised.
I would like so to share my configuration with you and I hope you can find something interesting in that. Of course, I’m not the “inventor” of this configuration, but it’s just my “best practice”.

  1. VM Ware machine with Win2008 R2 installed with the scope of Primary Domain Controller, with 512 MB  of RAM
  2. VM Ware machine with Win2008 R2, SQL Server 2008 R2 and SharePoint 2010 installed as a Single Server Farm , with 4096 GB of RAM

 

Primary Domain Controller

The primary domain controller will be an “easy” machine, configured as below, where the DNS server is installed and configured.
To install the DNS server, please take a look to this link

Once you have installed the DOMAIN, please create the following users:

  • SPAdmin: he will be the farm administrator of you SharePoint installation
  • AppPool: he will run the application pool of your web applications
  • DBAmin: he will be the administrator of the database server
  • Guest1, Guest2 and Guest3: you can use these users to configure different users of your site collections. It is very important you make your test with different roles.

Forward Lookup Zone

As I said above, for my experience you should have, as host header a real configuration and the OOB URL of SharePoint they aren’t. It’s not so hard, by the way, to have this feature.

  • Open your DNS manager
  • Open the item Forward Lookup Zone and open you domain item too
  • In order to have your items well organized create a new domain named SHAREPOINT. You’ll save here your host headers. When you create a new host header you’ll associate the name with an IP address you’ll set in the SharePoint machine.

SharePoint Server

Once you installed your new virtual machine with Windows 2008 R2 and SqlServer 2008 you have to add to the domain. In order to achieve this goal you have to add a new Network Adapter and configure as HOST ONLY.

When you have your new network adapter you’ll configure the IPV4 in order that your Active Directory machine will be the DNS server. You’ll add, after that, all the IP address you choose for the host headers. (Click ADVANCE in the main windows of IPV4).




After all these steps if you try to PING your host header by name (ex. das.sharepoint.sintax.local) you’ll obtain the response of your main SharePoint machine.

To install SharePoint I think is not necessary any specification. You’ll find on the Microsoft site all you need. My points are just when you’ll configure your new web application. We created a DNS specific for one web application: this means we can use our web application in the 80 port. See the image below and you’re done :)

In my experience this configuration can really help you to make your application with a real environment, most similar to the client configuration than the OOB SharePoint url and host header.

SharePoint

We’re back…day 1

By adminNo Comments

Based on the Google Analytics data this blog was read enough…but you understand the real meaning of “backup”  when you notice you don’t have one. So…for a crash happened on the server I lost everything…the MID file of Mysql were corrupted and I have to start again. I lost a lot of stuff and since today I’ll save my post also in a Word Document :)
Let’s keep in the loop and I hope the new articles will help someone over there…
m.

Various
Blue Taste Theme created by Jabox