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

Another link that i find helpful was

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>";
LtrCtr.Text =
LtrCtr.Text +=
"<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.
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;
                 //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";

Windows Process Activation Service (WAS) couldn't start , IIS also couldn't start

Ok that my first blog , I hope it will help full for you.
It was a regular day in work , i started my machine and tried to open my sharepoint 2010 site to continue what i was doing, ooooooooooops the HTTP 404 HELL message appeare , WHAT!!!!!.

ok , i checked my IIS and it found that it was not running , Simply i pressed start and again another error that informs me that IIS cannot start, after some googling if found that this message was Informing me that Windows Process Activation Service (WAS) is encountering a problem, i open the event viewer a found three errors:
1- Error ID: 5189
The Windows Process Activation Service failed to generate an application pool config file for application pool '*'. The error type is '0'. To resolve this issue, please ensure that the applicationhost.config file is correct and recommit the last configuration changes made. The data field contains the error number.
2-Error ID: 5036
The configuration manager for Windows Process Activation Service (WAS) did not initialize. The data field contains the error number.
3- Error ID: 5005
Windows Process Activation Service (WAS) is stopping because it encountered an error. The data field contains the error number.

OK, i gone googling for two Horus , where i found a common opinion that my applicationhost.config is corrupted , and i need to rebuild my OS , WHAAAAAAAAAAAT no, I'll lose my data ???!!!

but when i started to give up i found this magical Solution:

To fix this problem, follow these steps:
1.     Click Start , click All Programs, click Accessories, and then right-click Command Prompt.
2.     Click Run as administrator. If you are prompted for an administrator password, type the password. If you are prompted for confirmation, click Continue.
3.     At a command prompt, type the following command, and then press ENTER:
fsutil resource setautoreset true c:\
Note These steps assume that Windows is installed in the default location, on drive C. If this is not the case, adjust the drive letter of the folder path to match your configuration.
4.     Restart the computer.
And it worked ,,, THANX GOD.