Monday, September 17, 2012

Finding w3wp process id in SharePoint 2010


Go to CMD

Type cd c:\windows\system32\inetsrv

Type appcmd list wp

Powershell script to manage RemoteAdministratorAccessDenied


$snapin="Microsoft.SharePoint.PowerShell"
if (get-pssnapin
$snapin -ea "silentlycontinue") {
  write-host -f Green "PSsnapin
$snapin is loaded"
}

elseif
 (get-pssnapin $snapin -registered -ea "silentlycontinue") {
  write-host -f Green "PSsnapin
$snapin is registered"
  Add-PSSnapin
$snapin
  write-host -f Green "PSsnapin
$snapin is loaded"
}

else {

  write-host -f Red "PSSnapin
$snapin not found"
}

# get content web service

$contentService
= [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security

$contentService.RemoteAdministratorAccessDenied
= $false
# update the web service

$contentService.Update
()

SharePoint 2010 : Set SSO credentials


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Administration.Claims;
using Microsoft.Office.SecureStoreService.Server;
using Microsoft.BusinessData.Infrastructure.SecureStore;

namespace Laxmikant
{
    public static class SecureStoreManagement
    {

        internal static SecureString MakeSecureString(string str)
        {
            if (str == null)
            {
                return null;
            }
            SecureString str2 = new SecureString();
            char[] chArray = str.ToCharArray();
            for (int i = 0; i < chArray.Length; i++)
            {
                str2.AppendChar(chArray[i]);
                chArray[i] = '0';
            }
            return str2;
        }


        internal static SecureStoreServiceApplicationProxy GetSecureStoreProxy()
        {
            string siteurl = ConfigurationSettings.AppSettings["SPSiteUrl"];//from app.config
            using (SPSite site = new SPSite(siteurl))
            {
                SPServiceContext context =
                    SPServiceContext.GetContext(site);//SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);

                SecureStoreServiceApplicationProxy sssProxy = context.
                  GetDefaultProxy(typeof(SecureStoreServiceApplicationProxy)) as SecureStoreServiceApplicationProxy;


                return sssProxy;
            }

        }

        public static void SetCredentials(string userName, string userPassword, string targetApplicationID)
        {

            targetApplicationID = ConfigurationSettings.AppSettings["Name"]; //from app.config
            userName="SET USER NAME";
            userPassword="PASSWORD";
            IList creds = new List(2);
            creds.Add(new SecureStoreCredential(MakeSecureString(userName), SecureStoreCredentialType.WindowsUserName));
            creds.Add(new SecureStoreCredential(MakeSecureString(userPassword), SecureStoreCredentialType.WindowsPassword));

            using (SecureStoreCredentialCollection credentials = new SecureStoreCredentialCollection(creds))
            {
                SecureStoreServiceApplicationProxy sssProxy = GetSecureStoreProxy();
                if (sssProxy != null)
                {
                    SPClaim claim = SPClaimProviderManager.CreateUserClaim("farm admin username", SPOriginalIssuerType.Windows);
                    SecureStoreServiceClaim ssClaim = new SecureStoreServiceClaim(claim);
                    sssProxy.SetUserCredentials(targetApplicationID, ssClaim, credentials);

                    //if the target application  is using group type credentials then call this.//sssProxy.SetGroupCredentials(targetApplicationID, credentials);
                }
            }

        }

    }
}

SharePoint 2010: Retrieving Credentials from Secure Store Service


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.Office.SecureStoreService.Server;
using Microsoft.BusinessData.Infrastructure.SecureStore;
namespace SSSTEST
{
    class Program
  
{
        static void Main(string[] args)
        {
            //Retrieves the current users application username and password.
          
SecureStoreProvider prov = new SecureStoreProvider();
            using(SPSite site = new SPSite(http://SERVERNAME))
            {
                Console.WriteLine(site.RootWeb.CurrentUser.Name);
                SPServiceContext context = SPServiceContext.GetContext(site);
                prov.Context = context;
                string appID = "APPLICATIONID";
                try
              
{
                    SecureStoreCredentialCollection cc = prov.GetCredentials(appID);
                    foreach (SecureStoreCredential c in cc)
                    {
                        IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(c.Credential);
                        string sDecrypString = System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr);
                        Console.WriteLine(sDecrypString);
                    }
                }
                catch(Exceptionex)
                {
                    Console.WriteLine("Unable to get credentials for application "+ appID);
                    Console.WriteLine(ex.Message);
                }
                Console.ReadLine();
            }
        }
    }
}

Friday, September 14, 2012

Decomposition Tree

What is a Decomposition Tree?
PerformancePoint Services for SharePoint Server 2010 introduces the decomposition tree, an interactive arrangement of bar charts that makes it easy to explore contribution relationships. It provides an effective alternative to the "Drill Down To" feature in analytic charts.
How is Decomposition Tree Useful?
The Decomposition Tree is particularly useful because it enables you to do all of the following in one simple, easy-to-use browser window:
1.     Conduct root-cause analysis.
2.     See how an individual value in a report or a scorecard that uses SQL Server Analysis Services data can be broken down into its contributing members.
3.     Identify trends across individual members in a group.
4.     See members in a group in descending order, listed top to bottom.
5.     Choose which dimension you want to use for the next level of detail for an item in the Decomposition Tree.
6.     See all the properties that have been defined in the database for an individual member (you can do this when you are at the lowest level of detail in a dimension).
The SharePoint Server Decomposition Tree uses Silverlight technology, so you must have Microsoft Silverlight 2.0 or 3.0 installed on your computer.
Take advantage of products in the SharePoint family including SharePoint Server 2010, SharePoint Foundation 2010, SharePoint Server 2007 and associated free SharePoint templates or web parts.

SharePoint 10 questions



1.       SharePoint 2010 is Object Oriented architecture based solution?
a.        True
b.       False

2.       Can we remove Organization hierarchy from My Site in SharePoint 2010 without extra efforts?
a.        Yes
b.       No

3.       Can we use performance point services in site based on “Team Site” template?
a.        Yes
b.       No

4.       If some feature is deployed and running in production, can we extend its functionality?
a.        Yes
b.       No

5.       We can migrate a single site collection from MOSS 2007 to SharePoint 2010 using out of box features?
a.        Yes
b.       No

6.       Custom Master Pages will work fine after migration from MOSS 2007 to SharePoint 2010.
a.        True
b.       False

7.       SharePoint 2010 doesn’t support Site Directory.
a.        True
b.       False

8.       User can create more than one instance of User profile service.
a.        True
b.       False

9.       In SharePoint 2010, My site contains My Link web part by default.
a.        True.
b.       False.

10.    CustomMasterURL and DefaultMasterURL are same.
a.        True
b.       False

How to uninstall and install Reporting services on SQL Server 2008 R2.


Uninstall Reporting services.

 Using these steps, user can delete existing Reporting services from SQL Server without touching SQL Server database engine.
If system contains more than two reporting services instances then user can delete all those using the steps below. User need to run steps for each instance separately and restart the server after installation of each instance.

Steps:
1. Open “Programs and Features” (aka. Add/Remove Programs)
Select “Microsoft SQL Server 2008 R2″ (64-bit or 32-bit)
Click “Uninstall / Change”

http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_1-300x208.png
2. Click “Remove”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_2-300x248.png
3. Click “Ok”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_3-300x225.png
4. Select the SQL Server instance you wish to remove Reporting Services from in the “Instance to remove features from:” drop down box.

Click “Next >”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_4-300x225.png
5. Check “Reporting Services”
Click “Next >”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_5-300x225.png
6. Click “Next >”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_6-300x225.png
7. Verify the settings.
Click “Remove”
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_71-300x225.png
The removal of “Reporting Services” will progress…
http://www.gregorystrike.com/wp-content/uploads/2011/04/Reporting_Services_Step_8-300x225.png
8. Click “Close”
Removal is completed.
9.       Manually remove/backup the databases ReportServer and ReportServerTempDB from the SQL Server. If we already had some reports deployed to Reporting Services, we would do a backup of the databases and reconnect after the new installation. If we want to set a clean Reporting Services without reports, we can just remove them using Management Studio.
10.       Manually remove the virtual folders Reports and ReportServer from IIS (This is only for RS 2005. As you may know, RS 2008 doesn’t use IIS)
11.       Manually remove the folder of the instance of Reporting Services (For example for RS 2008 would be something like C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER). This folder is not removed automatically and, if we don’t remove it manually, the configuration files will contain information about the old configuration and we might conserve old problem if they existed.

Install Reporting services.

Reporting services configuration.

There are only 6 main steps to achieve this task assuming you already have an instance of SQL Server Reporting Services and SharePoint 2010.
I had created this starting from a clean installation of SQL Reporting Services so this guide will discuss the steps on configuring your SQL Reporting Services 2008 for integration with SharePoint 2010.
Step 1: Configuring SQL Reporting Services – Web Service URL
Simply go to Reporting Services Configuration Manager and choose Web Service URL and populate the following needed information. The fields are named properly so I guess there is no need for further explanation. What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-1.jpg?w=630&h=456
Step 2: Configuring SQL Reporting Services – Create a Report Database
Same here, fields need no further explanation except for one which is Native Mode and SharePoint Integrated mode which I will explain below.
Choose create a database or if you already have one choose an existing one. For this example, we will create a new one:
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-2.jpg?w=630&h=453
Connect to the database where you want your Report Data to be stored:
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-3.jpg?w=630&h=452
Give it a Name and a Report Server Mode.
With SharePoint Integrated Mode the report RDLs are stored on SharePoint and not in the Report Database. For this instance, we will use the SharePoint Integrated Mode:
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-4.jpg?w=630&h=453
Specify the credentials that the report server will use to connect to the database.
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-5.jpg?w=630&h=451
Review your configuration.
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-6.jpg?w=630&h=452
Then wait while it's configured.
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-7.jpg?w=630&h=451
Step 3: Configuring SQL Reporting Services – Create a Report Manager URL
What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.
http://anyrest.files.wordpress.com/2010/06/reporting-services-configuration-8.jpg?w=630&h=458
That’s it. At this point, your report server is configured for SharePoint Integration 2010.
Step 4: SharePoint Integration Configuration – Reporting Services Integration
Simply go to SharePoint 2010 Central Administration, then General Application Settings, then choose Reporting Services Integration.
http://anyrest.files.wordpress.com/2010/06/sharepoint-integration-configuration-1.jpg?w=630&h=318
Now populate the fields using the Web Service URL you had configured a while ago on Step 2 of this guide.
http://anyrest.files.wordpress.com/2010/06/sharepoint-integration-configuration-2.jpg?w=630&h=536
Once done, you will see the Activation State message.
http://anyrest.files.wordpress.com/2010/06/sharepoint-integration-configuration-3.jpg?w=630&h=537
Step 5: SharePoint Integration Configuration – Add a Report Server to the Integration
Now add the report server by putting the Server Name and the Server instance.
http://anyrest.files.wordpress.com/2010/06/sharepoint-integration-configuration-4.jpg?w=630&h=392
At this point it's all done, all you have to do now is try it out.
Step 6: Verify by Checking the Server and Uploading a Report
To verify if it's now integrated, go to Site Settings on your SharePoint Site, then Site Collection Features.
http://anyrest.files.wordpress.com/2010/06/verify-0a.jpg?w=258&h=419
http://anyrest.files.wordpress.com/2010/06/verify-0b.jpg?w=308&h=147
Check if the Report Server Integration Feature is Active, if not just click activate:
http://anyrest.files.wordpress.com/2010/06/verify-1.jpg?w=630&h=374
Now try to use the SQL Server Reporting Services Webpart:
http://anyrest.files.wordpress.com/2010/06/verify-2.jpg?w=630&h=250
http://anyrest.files.wordpress.com/2010/06/verify-3.jpg?w=629&h=468
Or you can also upload a report from a library.
http://anyrest.files.wordpress.com/2010/06/verify-4.jpg?w=630&h=382
That's it, so simple!


SharePoint 2010: How to create External Content type



External Content type allows you to make seamless interface between SharePoint 2010 and external data storage (ie. SQL server). Using External Content type, you can create an External List which stores the data to predefined storage. You can imagine of having a table with SharePoint list interface.
To create an External Content type, you need SharePoint Designer 2010. If you curious enough, the External Content type is enhancement of Business Data Connector (BDC) in previous version. It will now depend on Business Connectivity Services (BCS) – which more or less same as BDC.
Imagine that you have a table in SQL Database and you want to create SharePoint list which directly stores the data in that table.

1. Open SharePoint Designer and click on External Content Types
SPS2010_BDC-0000
2. Define the new External Content Type name. Then click on “External System” to start to connect to external Data Storage.
 SPS2010_BDC-0001
3. Define connection to external data storage. (ie. DB name,  and security)
SPS2010_BDC-0002
In my case, I use SQL server as my data storage.
SPS2010_BDC-0003
There are 3 security connection options in SQL Server Data Source:
– Connect with User’s Identity   => it will use running user’s credential to access to DB server. This implies that you need to manage user’s access rights in DB server.
– Connect with Impersonated Windows Identity => it will use impersonated Windows Identity ; usually the Application Pool identity.
– Connect with Impersonated Custom Identity => it will use specified user/password combination ; you need to define the Custom Identity separately.
 SPS2010_BDC-0004
Now, we already have the External List with the tables and views.
SPS2010_BDC-0005
4. Select any table for the External Content types. In this scenario, I select RequestTbl for my data storage. Right click on the selected table, and SPD2010 will show you the available operations.
The External Content Types requires at least “Read Item” and “Read List” operation.  In every operation you will need at least 1 identifier.
SPS2010_BDC-0006
Follow the wizard to create an operation.
SPS2010_BDC-0007
Don’t forget that every operation requires at least 1 identifier. You can choose ID field from the table.
 SPS2010_BDC-0008
SPS2010_BDC-0009
You can also define the default view filter, for example, by default this external content type will show only the first 100 items.
SPS2010_BDC-0010
5. Publish the new content type by click “Save” button.
SPS2010_BDC-0011

Now you already have new External Content Type. You can also create external content type to call .NET CLR and WCF Service. Next , how to use the external content type in a list.