Sunday, February 26, 2012

How find Sql objects used in procedures


SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%Products%'

Monday, February 13, 2012

Enable Claims based authentication on an existing web application in SharePoint



When you provision a web application in SharePoint 2010 you get the option to enable Claims based authentication. However, after the provisioning there's no option in the GUI to turn it on. PowerShell saves the day again with the option to change from classic to claims based authentication using the lines below.
$WebAppName = "http://test:8001"
$account = "Administrator" 
$wa = get-SPWebApplication $WebAppName
Set-SPwebApplication $wa –AuthenticationProvider (New-SPAuthenticationProvider) 
–Zone Default


The user running these command should be a member of the SharePoint_Shell_Access role on the config DB, and a member of the WSS_ADMIN_WPG local group.

Tuesday, February 7, 2012

Monday, February 6, 2012

Replacing Signout.aspx in SharePoint 2010

Yes, this was a common requirement in SharePoint 2007 and there wasn’t an easy and supportable approach to achieve that. Now in SharePoint 2010, it’s as easy as calling a method, specifying the page that you want to replace (for instance: Signout, error, access denied, ..) ,the URL of your new custom page and that's it!
The following feature receiver replaces the default SignOut page with a custom one on activation and resets the SignOut page to the default one on deactivation.

image

You can also replace other pages like AccessDenied.aspx, Confirmation.aspx, Error.aspx, Login.aspx, ReqAcc.aspx, SignOut.aspx or WebDeleted.aspx by specifying a member of SPWebApplication.SPCustomPage enum.

Custom sign out SharePoint page for FBA user.

Hi, everyone!
In my latest project we are using FBA users for our portal. And in the prototype of the master page such as generic web page we have login control with username, password boxes and ‘sing in’ button. If you will use for login just general sign in control of ASP .NET we will lose with authentication, exception will appear in the page. For fixing this problem we have to use SPClaimsUtility.
For example:
protected void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    e.Authenticated = 
SPClaimsUtility.AuthenticateFormsUser(Request.Url, signIn.UserName, signIn.Password);
}
But for sign out we have to create custom page for logout current user from portal. In all forums you can find information that’s you can use default signout.aspx page from 14 hive. But it’s true if you created custom login page inherited from SharePoint SignInPage. Default page is working incorrectly, it made sign out but doesn’t remove cookies from browser and the next page what you will see after signout, it will ‘Exception … ArgumentException … encodedValue’.
Insert the next following code to the page for clearing sign out.
protected override void OnLoad(EventArgs e)
{
 base.OnLoad(e);

 FormsAuthentication.SignOut();
 var authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
        // Clear .ASPAUTH cookie key.
 if (authCookie != null)
 {
  var myCookie = new HttpCookie(authCookie.Name)
               {Expires = DateTime.Now.AddDays(-1)};
  Response.Cookies.Add(myCookie);
 }

 SPIisSettings iisSettingsWithFallback = 
         Site.WebApplication.GetIisSettingsWithFallback(Site.Zone);
 if (iisSettingsWithFallback.UseClaimsAuthentication)
 {
  FederatedAuthentication.SessionAuthenticationModule.SignOut();
                // Clear FedAuth Cookie key
  FederatedAuthentication.SessionAuthenticationModule.DeleteSession                 TokenCookie();
 }


 SPUtility.Redirect(Web.ServerRelativeUrl, SPRedirectFlags.Default,
          Context);
}
That’s all what you need to add to the custom sign out page.

Sharepoint 2010 Form Based Authentication Using Active Directory

In this article I will try to show how we can use Active Directory Form Based Authentication in Sharepoint 2010 using Lightweight Directory Access Protocol (LDAP)
1. Add Connection string and membership provider in Central Administration web.config
1.png

2.png

3.png

4.png

NOTE: connectionString will differ based on domain configuration. Please contact you Administrator to provide the LDAP details.
2. Add Connection string and membership provider in SecurityTokenServiceApplication web.config
5.png

6.png

7.png

NOTE: connectionString will differ based on domain configuration. Please contact you Administrator to provide the LDAP details.

3. Create a new site with claim based authentication using Central Administration
8.png

Authentication : Claim Based
Claims Authentication Types: Enable Windows Authentication -> Integrated Windows authentication - > NTLM
Leave others to default

9.png
4. Now Create Site Collection at port 2233
10.png

And add Primary / Secondary Site Collection Administrators

11.png

12.png

So the resultant site will look like below.
13.png

5 Extend the web application to port 3322 and enable form based authentication (FBA)
14.png

Set the public URL Zone- Intranet or Extranet
5. Add Users to the Intranet zone using User Policy
15.png

16.png

17.png


18.png

Add more users as required with desired permissions.
Now open the newly extended application, and use your domain credentials to login the app.

19.png

20.png

Thursday, February 2, 2012

Customize Application pages top navigation bar


As known that in SharePoint 2010 the application pages have a new property
called DynamicMasterPageFile that enable them to use the site master page
instead of using the OOB application.master. But it would maintain the default
top navigation control although the one in site master page changes.
The reason it maintains the default top navigation is that application pages override
content inPlaceHolderTopNavBar with a user control called TopNavBar.ascx where
it contains the default top navigation control (AspMenu).
To have the application master use our top nav control, we need to find the
PlaceHolderTopNavBar and PlaceHolderHorizontalNav in the master page, set it Visible = false
and make sure they don’t enclose any controls.
<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server" Visible="false" />
<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server" Visible="false"/>