Showing posts with label SharePoint 2010 FBA. Show all posts
Showing posts with label SharePoint 2010 FBA. Show all posts

Monday, September 30, 2013

An exception occurred when trying to issue security token: Method is only supported if the user name parameter matches the user name in the current Windows Identity SharePoint 2010 FBA

You will see this error when you are using windowstokenroleprovider
<add applicationName="/" name="MyRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Change to sql role provider in your web.config file. check your central admin and

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken\web.config 
 files as well.



<add connectionStringName="SQLConnectionString" applicationName="/" description="Stores and retrieves roles from SQL Server" name="MyRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Wednesday, June 19, 2013

SPSecurityTokenService.Issue() failed: System.NullReferenceException: Object reference not set to an instance of an object

Basically it is looking for alternate access mapping. Below steps for creating alternate access mapping

Login to Central Admin.

1.            Go to Application Management.
2.            Under Web Applications click Configure alternate access mappings.
3.            Click on Add Internal URLs link on the tool bar. If you want to configure intranet or internet url’s click on Edit Public URLs
4.            In the URL protocol, host and port text box, type or verify the full URL of your site that is using the FBA Authentication.
5.            Set Zone to Default and save.


Thursday, June 13, 2013

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)

When you are working with SharePoint FBA controls like 

<asp:ChangePassword
 <asp:PasswordRecovery

you will get below error.

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue  
 at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)   
 at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedSuffix)   
 at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)   
 at Microsoft.SharePoint.SPWeb.InitializeSPRequest()   
 at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)   
 at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)   
 at Microsoft.SharePoint.ApplicationRuntime.BaseApplication.Application_PreRequestHandlerExecute(Object sender, EventArgs e)   
 at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)   
 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

There are many reasons to get this error.
1)      Make sure all the properties or attributes are correct for the control.
2)      Sometimes if you are working with forgot password or change password you can see the error. Cookies might create a problem as we are not logged in to change password.
3)      Add this attribute in the control MembershipProvider="giveyourmembershipname"
.CS FILE
public partial class ChangePassword : UnsecuredLayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }



        protected void myPasswordChanged(object sender, EventArgs e)
        {
            if (Request.Cookies[".ASPXAUTH"] != null)
            {
                HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
//myCookie.Path = ApplicationName();
                Response.Cookies.Add(myCookie);
                Response.Write("surya");
            }
        }

        //ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
    }

ASPX page
  <asp:ChangePassword ID="ChangePassword1" runat="server" MembershipProvider="RSCMemberProvider" OnChangedPassword="myPasswordChanged"
                 DisplayUserName="true" InstructionText="Enter your username and old password."
                 ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 CancelDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 >



Thursday, May 23, 2013

Remove providername of FBA user name in sharepoint 2010


#[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#add-pssnapin Microsoft.SharePoint.Powershell

<#
  Users.csv has list of all user names.

UserName
Suryap
Ravik
Johnp

#>

Copy below code and save it as .ps1 file. Open PowerShell window, run below script.
It will remove provider name from FBA user name.


$InputFile = "d:\surya\Users.csv"
$URL= "http://spdev5:8003"
$site = New-Object Microsoft.SharePoint.SPSite($URL)
$web = $site.openweb("")
$file = ipcsv $InputFile
$i = 1

#variables
      $fbaUserName= $null
      $fbaformattedlogin = $null
     
      foreach ($line in $file)
      {
            $fbaUserName = $line.UserName  #.csv file column name  

# update 'scmemberprovider' with your provider name

          $fbaformattedlogin = "i:0#.f|scmemberprovider|" + $fbaUserName   
          Set-SPUser $fbaformattedlogin -Web $URL -DisplayName $fbaUserName
          #Get-SPUser $fbaformattedlogin -Web $URL
           
           # $i++
           # if($i -eq 4)
          #{
           #       break;
          #}
      }          
$web.Dispose()
$site.Dispose()
     

Friday, May 17, 2013

Restore-SPSite : The content type text/html; charset=utf-8 of the response mess age does not match the content type of the binding (application/soap+msbin1). I f using a custom encoder, be sure that the IsContentTypeSupported method is imp lemented properly


I got this while restoring SharePoint 2010 site. After lot of efforts I have found something wrong in my web.config files.

Make sure all nodes are implemented properly in the web.config files especially when you are working with forms based configuration. 

if you have any duplicate nodes or spaces it might get this error.

Check below web.config files 

1) Central administration
2) Your Web App
3) 14\Security Token\Web.Config


for ex,


<connectionStrings>
      <add name="SQLConnectionString" connectionString="server=servername;UID=webuser;PWD=1230;database=UsersDB; connection reset=false; enlist=true; min pool size=1; max pool size=125" providerName="System.Data.SqlClient" />
</connectionStrings>


<membership defaultProvider="i">
      <providers>
        <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <<add connectionStringName="SQLConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="myMemberProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

      </providers>
    </membership>
    <roleManager defaultProvider="c" enabled="true" cacheRolesInCookie="false">
      <providers>
        <add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add connectionStringName="SQLConnectionString" applicationName="/" name="myRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />      </providers>
    </roleManager>





Thursday, January 31, 2013

Wednesday, June 27, 2012

SharePoint 2010 UAG : FormLoginDataDefinitions.xml and FormLoginCustom.xml


I followed below blog to configure single sign on in SharePoint.
http://microsoft-iag.blogspot.com/2010/10/uagenable-sso-by-passing-user.html

Andy provided only screen shots in his blog where people cannot copy easily. So I am providing code here to copy easily.

FormLoginDataDefinitions.xml

  <SCRIPT name="SharepointFBA">
      <!-- Possible value javascript or vbscript, if javascript tag could be omitted-->
      <LANGUAGE>javascript</LANGUAGE>
      <!-- Possible value cdata or base64, if javascript tag could be omitted-->
      <!-- Notice that searching for the element to submit is done by id, which by convention is seperated by underlines instead of dollar signs -->
      <BODY encoding="cdata">
        <![CDATA[

                              function FormLoginSubmit()
                              {   
                                    formsCol = document.forms;
                                    if (formsCol.length == 1)
                                    {
                                          try{
                                          var submitbtn = document.getElementById('ctl00_PlaceHolderMain_signInControl_login');
                                          if (submitbtn)
                                                submitbtn.click();
                                        }catch(e){}
                                    }
                                    return false;
                              }
                       
                        ]]>
      </BODY>
    </SCRIPT>


FormLoginCustom.xml

<WHLFILTFORMLOGIN ver="1.0">
      <!-- app_id added by configurator, dont edit -->
    <APPLICATION>
            <APPLICATION_TYPE>SharepointFBA</APPLICATION_TYPE>
           
            <!-- USAGE section is mandatory. "description=" could be "change_password" or "form_login" -->
            <USAGE description="form_login">

            <PRIMARY_HOST_URL><![CDATA[/_forms/default.aspx.*]]></PRIMARY_HOST_URL>
           
            <SCRIPT_NAME source="data_definition">SharepointFBA</SCRIPT_NAME>
           
            <!-- USER_AGENT could be of any type defined in FormLoginDataDefinitions.xml.  any, ie, netscape are used for back compatibility -->
            <USER_AGENT>
                  <!-- AGENT_TYPE could be of any type defined in FormLoginDataDefinitions.xml -->
                  <!-- "search=group" indicates all the values in the tag USER_AGENT_GROUP from FormLoginDataDefinitions.xml -->
                  <AGENT_TYPE search="group">all_supported</AGENT_TYPE>
                  <!-- POLICY should be "multiplatform" or "limited" -->
                  <!-- use "limited" if only "change_password" takes place -->
                  <POLICY>multiplatform</POLICY>
                  <!-- the name of the function to be injected to the form. Not recomended for customization-->
                  <SCRIPT_NAME source="data_definition">FormLoginHandler</SCRIPT_NAME>
            </USER_AGENT>
           
            <LOGIN_FORM>
                  <!-- one of NAME or ID could be used. Value could be blank if no form search required -->
                  <NAME>aspnetForm</NAME>
                  <!-- METHOD could be POST or GET -->
                  <METHOD>POST</METHOD>
                  <!-- CONTROL handling could be "dummy_value", "app_default", "real_value", "conf_default", "user_input" -->
                  <CONTROL handling="dummy_value">
                        <!-- TYPE could only be USER_NAME, PASSWORD, DOMAIN, DOMAIN_USER, USER_PROVIDED, NEW_PASSWORD -->
                        <TYPE>USER_NAME</TYPE>
                        <NAME>ctl00$PlaceHolderMain$signInControl$UserName</NAME>
                        <DEF_VALUE>siteusr</DEF_VALUE>
                  </CONTROL>
                  <CONTROL handling="dummy_value">
                        <TYPE>PASSWORD</TYPE>
                        <NAME>ctl00$PlaceHolderMain$signInControl$password</NAME>
                        <DEF_VALUE>sitepass</DEF_VALUE>
                  </CONTROL>
    </LOGIN_FORM>
     
            </USAGE>
      </APPLICATION>
</WHLFILTFORMLOGIN>

Followers