Monday, 30 September 2013

What is the difference between a SharePoint Audience and a Group ?

What is a SharePoint Group ?

A SharePoint group can be created by a user from within SharePoint and requires that user to manually add or remove users. A SharePoint group can also contain many Active Directory groups (which themselves can contain child AD groups). 

SharePoint groups are often used to make securing "things" in SharePoint easier. For example, if you want to secure 10 documents so that 300 users can see them, it's easier to put the 300 users into a group and give the group permissions to the 10 documents. This way new users can be added to the group, without having to worry about the 10 documents. They will immediately gain access by being a member of the group.

What is a SharePoint Audience ?

SharePoint Audiences are dynamically created based on a set of rules. If users meet the audience criteria they will automatically become a member of the audience. Audiences can be compiled regularly using a background SharePoint job. Every time the schedule 'kicks off' the Active Directory will be searched for users who meet the criteria and will be included in (or excluded from) the audience. 

This means that the audience membership can change over time, however each time the audience is compiled, only users who meet the specified criteria will be included. By using rules or criteria (assuming that your base information is kept up to date) it means that you can be assured that the right users are contained in the audience and that manual maintenance of audience members is not required.

What are the differences ?

  • An Audience can scale to hundreds of thousands of users, a SharePoint group is limited to a few thousand and has scalability problems at the top end.
  • A SharePoint group can be used to secure a site, document library, or document. A SharePoint audience cannot.
  • The membership of a SharePoint group has to be manually managed. The membership of a SharePoint audience is automatically managed based on rules configured by your Central Administrator.
  • A SharePoint audience can only be created in MOSS 2007 or SharePoint Server - Standard / Enterprise 2010. A SharePoint group can be used in all versions of SharePoint including WSS and Foundation.
  • A change in membership to a SharePoint group is immediate. The membership of a SharePoint audience will only change when the next scheduled run happens. (In most large organizations this is usually nightly as it can be quite an intensive process).
  • A SharePoint Central Administrator can create an audience. SharePoint site admins usually are responsible for creating groups. 
  • SharePoint audiences are globally-scoped, meaning they can be used in all site collections and sites. SharePoint groups are scoped up to Site Collection level.
  • Both SharePoint audiences and groups can be used to target web parts and also content in lists. This means that if you are a member of a group or audience, content can be selectively shown to you. This adds some degree of personalization to SharePoint.

Sunday, 29 September 2013

How to: Migrate MOSS 2007 to SharePoint 2010

How to: Migrate MOSS 2007 to SharePoint 2010

Migration from MOSS 2007 to SharePoint 2010


Nowadays we are getting multiple projects to migrate MOSS 2007 to SharePoint 2010. By Default, SharePoint 2010 will support to migrate the contents from MOSS 2007 to SP 2010.


To complete the migration successfully, I am giving some additional and easy steps to follow:


Steps to Migrate the MOSS 2007 to SharePoint 2010 Contents:
1. Take a backup of existing MOSS 2007 content database using SQL server management studio. Before taking SQL backup, you can truncate the "log" file from SQL server. The log file will slow down your migration process.


2. Restore the Content DB in target SQL Server using SQL server management studio.


3. Create an dummy SharePoint 2010 web application without a top level site collection. (Do not refer the newly attached database name while creating teh web application)


4. Remove the Content Data Base from the newly created dummy website through central admin as mentioned below:


i. Go to "Application Management" --> "Manage Content Databases" --> Select the specific web application.








ii.select the "Remove content database" checkbox. and click OK twice as mentioned below.












5. Then add the Content DataBase through STSADM command to the specific web application.
stsadm -o addcontentdb -url "http://172.16.0.148:3030" -databasename "WSS_Content_Old_ContentDB"


6. Now browse the application and do the visual upgrade in "Settings" page.


Thats it....


Updates:
1. Sometimes, you will not be able to browse the application since you may not be the administrator of the migrated application. At that time you need to add your name/administrator name as "Site collection Administrator" through central admin URL as mentioned below.


i. Application Management --> "Change site collection administrators"











ii. Select your web application and update the correct Primary and secondary administrators.












2. If you are not able to update anything in the newly migrated application, the application may be in Read-Only mode. Or sometimes, the administrator (system account) will not be able to see the Administration links. To fix this, you need to provide read-write access to the newly created web application as I mentioned below.


stsadm -o setsitelock -url "http://servername" -lock none


3. During the migration process, you check the status of the migration in "Upgrade and Migration" section of central admin.


Sometimes, the migration status may shown as "failed". This is because of the custom solutions which are deployed in the MOSS 2007. You can simply ignore them.




But once the "Addcontentdb" command is completed, the database status should be "No action required". You can check the status under the "Upgrade and Migration" --> "Review database status" in central admin.







4. If you are getting
 "Database is in compatibility range and upgrade is recommended" error, then you need to run the
PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures command.

Thursday, 26 September 2013

Programmatically Change Sharepoint Web Application IP Address

Programmatically Change Sharepoint Web Application IP Address


Recently I was asked about changing a Sharepoint Web Application IP Addresses programatically, is this possible and how will it affect the Sharepoint sites?

I did some testing and it turns out that it is indeed possible to change the IIS Website IP Address without impacting the Sharepoint Web Application(s). For the most part Sharepoint does not care about the IP Address that are assigned to it's Web Application(s), what it cares about is how the IIS sites are mapped to it's Site Collections. The mapping is done via host header in IIS and Alternate Access Mappings in Sharepoint.

Hopefully there are no Sharepoint sites that are accessed using IP Addresses, if so when the IP Address changes, things will break.

Using  Host Headers and Alternate Access Mappings allow access via friendly names, these names are only bound by DNS so as

To create a friendly name like 'Portal' first I'll create a host header in IIS to my Sharepoint site, host headers allow me to have several IIS sites and only require one IP address.

In IIS select the Sharepoint site and click Bindings from the Actions menu, enter a friendly name, in my case 'Portal'



 Next Ill create a new A record on my DNS server so that the name Portal resolves to my Sharepoint Web Applications IP Address.

Next I'll create a Sharepoint Alternate Access Mapping so that Sharepoint knows what to do when it receives a request for this friendly name 'Portal'

Open Sharepoint Central Administration, select Application Management and under Web Applications select configure alternate access mappings.

Select the alternate access mapping collection for your site and select edit public URLs


Next add the url for your friendly name in one of the zone text boxes


After this configuration is complete Sharepoint can be accessed by typing http://portal. Next I want to programmatically change the IP address of my Sharepoint Web Application.

I found a Powershell script to perform this exact task.


$oldIp = "172.16.3.214"
$newIp = "172.16.3.215"


# Get all objects at IIS://Localhost/W3SVC
$iisObjects = new-object `
    System.DirectoryServices.DirectoryEntry("IIS://Localhost/W3SVC")


foreach($site in $iisObjects.psbase.Children)
{
    # Is object a website?
    if($site.psbase.SchemaClassName -eq "IIsWebServer")
    {
     $siteID = $site.psbase.Name


     # Grab bindings and cast to array
     $bindings = [array]$site.psbase.Properties["ServerBindings"].Value


     $hasChanged = $false
     $c = 0


     foreach($binding in $bindings)
     {
     # Only change if IP address is one we're interested in
     if($binding.IndexOf($oldIp) -gt -1)
     {
     $newBinding = $binding.Replace($oldIp, $newIp)
     Write-Output "$siteID: $binding -> $newBinding"


     $bindings[$c] = $newBinding
     $hasChanged = $true
     }
     $c++
     }


     if($hasChanged)
     {
     # Only update if something changed
     $site.psbase.Properties["ServerBindings"].Value = $bindings


     # Comment out this line to simulate updates.
     $site.psbase.CommitChanges()


     Write-Output "Committed change for $siteID"
     Write-Output "========================="
     }
    }
}

Note: Remember DNS will have to be changed first to accommodate the IP Address change.

Provided there are multiple IP Addresses available on the Sharepoint server, this script will look for an old IP Address and update the IIS website to the new IP Address. Again Sharepoint does not care about the IP Address but it only cares about the request coming to it via IIS and matching the name with a Site Collection.

Hopefully this is helpful, it can be useful in fail over scenarios where re-iping at the fail over site is required.

Different ways to deploy a webpart on Sharepoint 2010

When you are done developing a WebPart, you need to deploy it to the SharePoint server. However, depending on your server setup, you may have to use specific deployment methodology and that is why it is important to know your options. This post describes different ways to achieve this goal.

Basic understanding

Whatever method you use to develop your WebPart, you will always end up with a WebPart DLL and in some cases you will have WSP file (both of these files are in debug folder of your project). It is the DLL file that plays a key role in getting your WebPart inside SharePoint server. 

Ways to deploy a WebPart

There are four ways we can deploy a WebPart on SharePoint server that I will cover in this post: 

  1. Using Visual Studio to deploy the solution
  2. Manually moving the DLL to the server
  3. Uploading WSP to SharePoint server
  4. Deploying through command prompt

Pre-Requisites

I am assuming that you are all done with the development and are now ready to deploy. In these examples I have a project name "FeedbackWP" that I need to deploy.

Deploying through Visual Studio

Once the coding is complete, click on build > deploy



In the output window you should see the deployment success status. 


For next steps please look at "After you webpart is deployed" section at the end of this post.



 Deploying by manually moving the DLL


Build the solution 




If no error returned by the compiler, copy the DLL from your project bin > Debug directory to the bin directory of your WSS site (C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin). 






Go to (C:\inetpub\wwwroot\wss\VirtualDirectories\80\) and modify the Web.Config file for the WSS site to declare the custom web part as a safe control by adding the following code within the <SafeControls> tag.

<SafeControl Assembly="DLL-Name-Here" Namespace="DLL-Name NameSpaceHere" TypeName="*" Safe="True" />

In my case my dll name is feedBackWP and the namespace of my webpart is InputForm; so my SafeControl entry looks like:

<SafeControl Assembly="feedBackWP" Namespace="feedBackWP.InputForm" TypeName="*" Safe="True" />

And my webconfig looks like the image below:



Now we need to add this webpart to our Sharepoint gallery.

Click on Site Actions -> Site Settings -> Web Parts. 



From Web Parts page click on Documents > New Document





New Document will bring up a pop-up window. This window should have your new web part listed. Select your webpart from the list and click on Populate Gallery.


If the import is successful, you will see the web part in Web part gallery list. 



For next steps please look at "After you webpart is deployed" section at the end of this post.



Deploying by uploading WSP to SharePoint server

Build the solution 




If no error returned by the compiler, you will have WSP file in your project bin > Debug.

  Open Sharepoint and click on Site Actions -> Site Settings -> solutions. 

  



From solutions page click on solutions on top and after clicking it, you should see upload solution tab.





Click on upload solution and it will bring up a popoup to upload your webpart.


Upload your WSP file.


If uploading is successfull, you should see the webpart appear in the solutions list.


Activate the solution and thats it.





For next steps please look at "After you webpart is deployed" section at the end of this post.



Deploying through command prompt

Build the solution 




If no error returned by the compiler, you will have WSP file in your project bin > Debug.

Copy the wsp file on the server and open up a command line and navigate to the 12-hive bin folder.
(my 12-hive bin folder is C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
Enter the following commands :

stsadm -o addsolution -filename WSP FILE NAME WITH LOCATION

stsadm -o deploysolution -name WSP FILE NAME -immediate -allowGacDeployment -url  SITEURL   


So in my case these commands become:

stsadm -o addsolution -filename c:/feedBackWP.wsp 

stsadm -o deploysolution -name feedBackWP.wsp -immediate -allowGacDeployment -url ht
tp://bk-laptop-hp/
 

  

For next steps please look at "After you webpart is deployed" section.


After your Webpart is deployed

Go to the SharePoint site and click on Site Action > New Page. 






From new page click on Insert and then on WebPart. 





From WebPart list click on custom (NOTE: In some cases this is miscellaneous instead of custom). This should bring up our WebPart on the right hand side. 



With the WebPart selected click on the add button.