Wednesday, November 28, 2012

Upgrading from SharePoint 2010 Windows classic Authintecation to SharePoint 2013 Claims



  • SharePoint 15 continues to offer support for both claims and classic authentication modes
  • However claims authentication is THE default authentication option now
    • Classic authentication mode is still there, but can only be managed in PowerShell – it’s gone from the UI
    • Support for classic mode is deprecated and will go away in a future release, so we recommend moving to Claims
    • There also a new process to migrate accounts from Windows classic to Windows claims
  • The MigrateUsers method in SharePoint 2010 is no longer the correct way to migrate accounts – it is now deprecated
  • A new cmdlet has been created called Convert-SPWebApplication
  • A simple example – you have a Windows classic web application
    • Run Convert-SPWebApplication -Identity "http://yourWebapp" -To Claims –RetainPermissions [-Force]
       
        Other Claims Migration Scenarios:
§  You have an existing Windows claims application and you want to bring over content from a SharePoint 2010 Windows classic web app
§  Option 1 (the safest):
§  Create a web application in o15 that uses Windows classic authentication
§  Attach the SharePoint 2010 content database to this o15 web app
§  Attaching it will upgrade it to the o15 database format, so verify that it is working correctly after attach
§  Run the Convert-SPWebApplication command on the o15 web app to convert the users from Windows classic to Windows claims
§  Detach the content database from the o15 Windows classic web app
§  Attach the content database to it’s final o15 Windows claims web app
§  Option 2 (the quickest):
§  Attach the content DB to an existing Windows claims web application Run the Convert-SPWebApplication cmdlet again on the web app

Variations propagate pages on your terms



Page propagation is triggered by publishing a page on the source variation site by default. Each time you publish a source page, the Variations Event Receiver adds a work item to the Variations Propagate Pages timer job queue. When the timer job runs, it will begin executing the first 100 page propagation work items. For each work item, Variations will copy the source page to all target sites, creating the page if it does not yet exist, or appending a draft minor version if the target page does already exist.

In some cases, users might not want changes to a page on the source to necessarily propagate to all targets. That is, users might want to make source-local changes and have the option to make changes globally applicable when they want. This often takes the form of a question like "How can I stop variations from overwriting my target pages every time I publish a source page?" Variations in SharePoint 2010 helps you do this.

The Answer is Enable On-Demand Page Propagation.


Hope this is a useful piece of Information J

Thursday, March 8, 2012

EMail your Datagrid SharePoint 2010

Hello all,

In this post we will discuss the shortest way to send the Results of a data grid in the content of E-Mail with its HTML.

Our Game Plan:
1- Do your logic Bind the Data grid get the result.
2- Extract the HTML of the data grid.
3- Build the XSL fro your Mail formattting.
4- Send the mail.

I'll skip step 1 as it is very easy and you will find it all over the Internet.

Assuming we have our Data grid binded noe we need to extract thos results as HTML how we will do that by,
this Method
private string GetGridHTML()
        {
            StringBuilder SB = new StringBuilder();
            StringWriter SW = new StringWriter(SB);
            HtmlTextWriter htmlTW = new HtmlTextWriter(SW);

            grdMyDataGrid.RenderControl(htmlTW);

            string dataGridHTML = SB.ToString();

            //dataGridHTML = Server.HtmlEncode(dataGridHTML);

            return dataGridHTML;
        }

this code will give exception GridView must be placed inside a form tag with runat=“server” even after the GridView is within a form tag

You are calling GridView.RenderControl(htmlTextWriter), hence the page raises an exception that a Server-Control was rendered outside of a Form.
You could avoid this execption by overriding VerifyRenderingInServerForm

public override void VerifyRenderingInServerForm(Control control)
{
  /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
     server control at run time. */
}
 
Ok now we have our Data grid content HTML .


Monday, July 25, 2011

Applying your FBA configuration to production environment - Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) +1161013

OK, we have discussed the steps of configuring your SharePoint site to use FBA , I've configured it many and many times , but there was a case where it was required that the Web Front End for our site will be on two servers , ok a little detail i found that when you deploy your site in several WFEs  you need to configure in three places
1- Your Central Admin Application pool

2- your STS (Security Token Service).

3- In each WFE

so what, I configured them all as usual , every thing is fine , testing the login page , oooooooooooooooops an error page (NOT SHAREPOINT ERROR) ASP.NET error page, ok calm down enable custom error  , and i got - Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) +1161013- what is this ??? , I assumed that the error was not ASP its SharePoint ,opened the LOGS file and i found that the user i created from the central admin sever , couldn't be verified by  the WFE as i configured my ASPMembership provider to encrypt the passwords, And of course as we all know that the password is encrypted by the machine-key which differs from one machine to the other , ok there is a solution for this issue , open your web.config on one of your WFEs , find the "machineKey" tag it looks like the following <machineKey validationKey="424B56AB4FC235300974BB13CE70F69987166E4F690DFF0F" decryptionKey="FED66B56701EB68F15C714D84DC8C7434F2445167DE802E8" validation="SHA1" /> copy it and paste it to all the WFEs using your site , Now all the WFEs are Decrypting-Encrypting using the same key. Mission Accomplished !!!!   

Thursday, May 5, 2011

Forms Based Authentication for sharepoint 2010 step by step and Creating new ASP.NET users from sharepoint site

OK it is very easy to be able to have a Form Based Authentication site in sharepoint 2010 following those steps in that link http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/

Another link that i find helpful was http://msdn.microsoft.com/en-us/library/bb975136(v=office.12).aspx

But I'm not writing down this blog for those steps mainly I wanted to be able to create new ASP.NET membership users using my custom webpart.

so what is our mission:
1. Configure SQL for membership store
  • Create database
  • Create SQL User
  • Add SQL user to database
2. Configure Central Admin to use SQL membership store
3. Configure Secure Store Web Service to use SQL membership store
4. Create new Web Application for extranet site
5. Configure Extranet site to use SQL membership store

those steps are explained on the first link.

6. Configure Our site to enable anomynos access.
7. Create a new Sign Up WebPart.

Lets begin:
6. Configure Our site to enable anomynos access.

1- First you need to open up your Central Administration page
2- Under Application Management section click Manage Web Application and then you will find on your Ribbon Anonymous Policy click it and then choose any permission level you want but not the none choice
3- if you found that this option is disabled so you need to go to the security page on your central admin and then find under the General Security section
Specify authentication providers link click it and insure that your web application you created previously is selected , click default and then check the Enable anonymous access checkbox , and  then do step no. 2.
4- Now Open your recently created web Application (for example http://win-1eppeqik472:500/ )
5- Go to Site Actions -> Site Permissions on your ribbon you will find Anonymous Access click it and then choose entire site (Just for Example).

7. Create a new Sign Up WebPart.
OK now we want to be able to sign up to this site:

OK lets see the final Result "That helps very much"




Successfully Crearted a user (NewUser)


Sign in Page
so you don't say there is somthing sniky right there





Now how is this done :

First of all my MembershipProvider is FBAMembershipProvider
so I'll get an instance of that provider and create a user by it:


using System.Web.Security;
MembershipCreateStatus Status;

MembershipProvider FBAProvider = Membership.Providers["FBAMembershipProvider"];
MembershipUser NewUser = FBAProvider.CreateUser(this.txtUserName.Text, txtPassword.Text, txtEMail.Text, txtQuestion.Text, txtAnswer.Text, true, (object)Guid.NewGuid(), out Status);
new LiteralControl();
if (NewUser == null)
string Msg = GetErrorMessage(Status);"<h3>" + Msg + "</h3>";
else{
LtrCtr.Text =
LtrCtr.Text +=
ReIntializeControls();
}
"<h3>Congratulations Your New Login Name is : " + NewUser.UserName + " , Thank you for Signing Up</h3>";"<h3>You can now sign in by clicking the sign in link in the upper right of your screen</h3>";


LtrCtr =

{

LtrCtr.Text =
}
 



Wednesday, May 4, 2011

Setting a variation label to be the default entry to a publishing Site

 ·         Directly edit the VariationsRootLanding.ascx file.
This is the quickest way to edit the logic. Edit the logic in the VariationsRootLanding.ascx file as needed, on the front-end Web server file system.
·         Navigate to the path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES” here you will find the VariationsRootLanding.ascx file open the file and to edit.
To modify the root landing logic to detect when a functioning Web site is present
1.       In the GetRedirectUrl() section, find this line of code.
return (string.IsNullOrEmpty(matchedUrl) ? sourceLabelUrl : matchedUrl);
2.       Replace the line of code in Step 1 with the following code.
Note:
That I'm redirecting to my source Variation label with the index of "0".

       #region Redirecting to a custom variation
       // Customization for handling matchedUrl not valid.
       // (For example, a content deployed target site collection,
       // without source hierarchy.)
       matchedUrl = (string.IsNullOrEmpty(matchedUrl) ? sourceLabelUrl : matchedUrl);
       using (SPSite site = new SPSite(matchedUrl))
       using (SPWeb web = site.OpenWeb())
       {
            // If matchedUrl is the same as the URL of the Web
            // that you just opened, then matchedUrl is valid.
            if (string.Compare(matchedUrl, web.Url, StringComparison.OrdinalIgnoreCase) == 0 && web.DoesUserHavePermissions(SPBasePermissions.Open))
            {
                //Target URL is valid; return it.
                //return matchedUrl;
                SPSite Site = new SPSite(http://win-1eppeqik472/sites/Publishing);
                SPWeb Web = Site.RootWeb;
                Guid varListId = new Guid(Web.AllProperties["_VarLabelsListId"] as string);
                SPList varList = Web.Lists[varListId];
                String URL = varList.Items[0].Web.Url;
                URL += "/" + varList.Items[0].Name + "/Pages/default.aspx";
                return URL;
            }
            else
            {
                 //Target URL was NOT valid; the variation label is missing.
                 //Perform logic here to redirect the user appropriately.
                 //If nothing is done here, then this function returns null
                 //and the landing behavior reverts to the
                 //VariationsRootLandingRunTime control.
                 //This control displays a simple error message that
                 //indicates that it could not find an appropriate subsite to
                 //redirect to.
                 return "http://win-1eppeqik472/sites/Publishing/Arabic/Pages/default.aspx";
             }
          }