Saturday, September 10, 2016

Configure FBA in SharePoint 2013

Configuring FBA in SharePoint 2013
--------------------------------------------------

1.  Run the  Aspnet_regsql. exe  from the following path for framwork 4.0

       Path:  %windir%\Microsoft.NET\Framework64\v4.0.30319

2. Default Database Will be created as aspnetdb

3. create a user in security/logins and give right to user as FBA_USER_ACCOUNT or any name.

4. After that you need to place membership and role provider to 3 Web config files.

   1. Central admin
   2. Web application
   3. STS service app
5. Open Central admin config file and place the below markup at specific place.

Find this:
--------------

<sessionState mode="InProc" timeout="20" cookieless="UseCookies" />

//******************************************* These markup ***********************************************************
    <membership>
      <providers>
          <add name="FBA_MEMBERSHIP" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" enablePasswordReset="true" enablePasswordRetrieval="false" passwordFormat="Clear" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" />
      </providers>
    </membership>
    <roleManager>
      <providers>
          <add name="ROLE_PROVIDER" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" />
      </providers>
    </roleManager>

//**********************************************End Markup ****************************************************************
  </system.web>
  <system.webServer>

Now Find in the end:  </configuration> 
------------ 
//******************************************************************************************

 <connectionStrings>
        <add connectionString="Server=CLIENTVM01;Database=aspnetdb ;Uid=FBA_USER_ACCOUNT; Pwd=user@123" name="FBA_CON" />
    </connectionStrings>
//****************************************************************************************
</configuration>

6. Now Open the Web Application config file

Find: <machineKey validationKey and place this below this tag

//*****************************************************************************************************************
 <membership defaultProvider="i">
      <providers>
        <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <add name="FBA_MEMBERSHIP" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" enablePasswordReset="true" enablePasswordRetrieval="false" passwordFormat="Clear" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" />
      </providers>
    </membership>
    <roleManager cacheRolesInCookie="false" defaultProvider="c" enabled="true">
      <providers>
        <add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        <add name="ROLE_PROVIDER" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" />
      </providers>
    </roleManager>

//************************************************************************************************************************
  </system.web>
  <system.webServer>

7. Now open the STS config file:
    Find: </system.net>

Place this markup below this
//************************************************************************************************************************
<connectionStrings>
    <add connectionString="Server=CLIENTVM01;Database=aspnetdb ;Uid=FBA_USER_ACCOUNT; Pwd=user@123" name="FBA_CON" />
  </connectionStrings>
  <system.web>
    <roleManager>
      <providers>
        <add name="ROLE_PROVIDER" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" />
      </providers>
    </roleManager>
    <membership>
      <providers>
        <add name="FBA_MEMBERSHIP" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" connectionStringName="FBA_CON" enablePasswordReset="true" enablePasswordRetrieval="false" passwordFormat="Clear" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" />
      </providers>
    </membership>
</system.web>

//*************************************************************************************************************************** 
</configuration>

8: Now Create users in IIS, Making Membership and Role manger as default which you created now.

9. After creating the users make Membership (i) and Role manager (c) as default, OOBs

10. add FBA users to site and login.





Saturday, September 3, 2016

How to write a log in txt File

How to write a log in txt File

Using System.Diagnostic;

 public void WriteLogg(string errorDescription)
        {
            System.IO.StreamWriter objWriteLog = System.IO.File.AppendText("C:\\temp" + "\\log.txt");
            try
            {
                FileInfo fileInfo = new FileInfo("C:\\temp\\log.txt");
                if (!fileInfo.Exists)
                {
                    File.Create("C:\\temp\\log.txt");
                }
                objWriteLog.WriteLine("Date and Time : " + DateTime.Now.ToString());
                objWriteLog.WriteLine("errorDescription : " + errorDescription);

            }
            catch (Exception ex)
            {
                EventLog eventLog = new EventLog();
                eventLog.Source = "DocEvent";
                eventLog.WriteEntry(errorDescription + "- er: " + ex, EventLogEntryType.Warning);
            }
            finally
            {
                objWriteLog.Close();
            }
        }

Thursday, August 11, 2016

VM Ware failed to open issues, Failed to lock the file! VMWare vietual disk (vmdk)

Source: http://www.networknet.nl/apps/wp/archives/396/comment-page-1
I copied one of my Windows XP virtual machine running on a VMWare Server 1.02 system locally to my workstation. After the files were copied I opened the vmx file with VMWare Workstation 6 and received the following error below after trying to start the virtual machine. The virrtual machine contained one snapshot on the VMWare Server.

Cannot open the disk ‘C:\VM-machines\Windows XP-001\Windows XP Professional-000001.vmdk’ or one of the snapshot disks it depends on. Reason: Failed to lock the file.

clip_image002
Locate the virtual machine in Windows Explorer and delete any .lck folders
image
Start the virtual machine. If boot process will fail, try to Map the virtual hard disk to Z:\ for example.
image
clip_image008
I then disconnect the virtual hard disk and tried again. The virtual machine boot without any problem and my snapshot was still valid. Deleting the .lck folder saved me a lot of work.

Tuesday, August 9, 2016

Resolution for [Update panel buttons not triggering in SharePoint 2013 web part.] Change in Master Page

Resolution for [Update panel button not working in web part.]

Replace your <body> content with  below content with in SharePoint 2013 master page
 ------------------------------------------------------------------------------------------------------------
 Master Page issue

<body>
        <SharePoint:ImageLink runat="server" />
        <SharePoint:SPNoScript runat="server" />
        <SharePoint:SPClientIDGenerator runat="server" ServerControlID="DeltaPlaceHolderMain;DeltaPlaceHolderPageTitleInTitleArea;DeltaPlaceHolderUtilityContent" />
        <SharePoint:SharePointForm runat="server" onsubmit="if (typeof(_spFormOnSubmitWrapper) != 'undefined') {return _spFormOnSubmitWrapper();} else {return true;}">
            <script type="text/javascript"> var submitHook = function () { return false; }; theForm._spOldSubmit = theForm.submit; theForm.submit = function () { if (!submitHook()) { this._spOldSubmit(); } }; </script>
            <SharePoint:AjaxDelta ID="DeltaSPWebPartManager" runat="server">
                <WebPartPages:SPWebPartManager runat="Server" />
            </SharePoint:AjaxDelta>
            <asp:ScriptManager ID="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true" />
            <SharePoint:AjaxDelta ID="DeltaDelegateControls" runat="server">
                <SharePoint:DelegateControl runat="server" ControlId="GlobalNavigation" />
                <SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server" Visible="false" />
            </SharePoint:AjaxDelta>
            <SharePoint:AjaxDelta ID="DeltaPlaceHolderPageTitleInTitleArea" runat="server">
                <asp:ContentPlaceHolder ID="PlaceHolderPageTitleInTitleArea" runat="server">
                </asp:ContentPlaceHolder>
            </SharePoint:AjaxDelta>
            <div id="sideNavBox" class="ms-dialogHidden ms-forceWrap ms-noList">
                <div class="ms-core-navigation">
                    <SharePoint:AjaxDelta ID="DeltaPlaceHolderLeftNavBar" BlockElement="true" CssClass="ms-core-navigation" role="navigation" runat="server">
                        <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBar" runat="server">
                            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarTop" Visible="false" runat="server">
                            </asp:ContentPlaceHolder>
                            <asp:ContentPlaceHolder ID="PlaceHolderQuickLaunchTop" Visible="false" runat="server" />
                            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarDataSource" Visible="false" runat="server" />
                            <asp:ContentPlaceHolder ID="PlaceHolderCalendarNavigator" Visible="false" runat="server" />
                            <asp:ContentPlaceHolder ID="PlaceHolderLeftActions" Visible="false" runat="server" />
                            <asp:ContentPlaceHolder ID="PlaceHolderQuickLaunchBottom" Visible="false" runat="server" />
                        </asp:ContentPlaceHolder>
                    </SharePoint:AjaxDelta>
                </div>
            </div>
            <div id="TurnOnAccessibility" style="display: none" class="s4-notdlg noindex">
                <a id="linkTurnOnAcc" href="#" class="ms-accessible ms-acc-button" onclick="SetIsAccessibilityFeatureEnabled(true);UpdateAccessibilityUI();document.getElementById('linkTurnOffAcc').focus();return false;">
                    <SharePoint:EncodedLiteral runat="server" Text="<%$Resources:wss,master_turnonaccessibility%>" EncodeMethod="HtmlEncode" /></a>
            </div>
            <div id="TurnOffAccessibility" style="display: none" class="s4-notdlg noindex">
                <a id="linkTurnOffAcc" href="#" class="ms-accessible ms-acc-button" onclick="SetIsAccessibilityFeatureEnabled(false);UpdateAccessibilityUI();document.getElementById('linkTurnOnAcc').focus();return false;">
                    <SharePoint:EncodedLiteral runat="server" Text="<%$Resources:wss,master_turnoffaccessibility%>" EncodeMethod="HtmlEncode" /></a>
            </div>


Friday, June 24, 2016

Apps Development Visual Studio Issues Resolution


I was trying to install SharePoint 2013 on premise development environment and encountered the following issues while deploying the app using Visual studio 2013.
Please refer these articles for configuration settings.
Error 1:
Error occurred in deployment step ‘Install app for SharePoint’: The System Account cannot perform this action.
Error 2:
The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.
Error 3:
Error occurred in deployment step ‘Install app for SharePoint’: We’re sorry, we weren’t able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator.
Solution:
For error 1, follow these instructions:
a. Create a new domain account DOMAIN\myApp_Admin
b. add DOMAIN\myApp_Admin to local admin group
c. add DOMAIN\myApp_Admin to Farm Administrators group
   Central Admin site –> Site Settings –> People and groups
   Add DOMAIN\myApp_Admin
For error 2 & 3, follow these instructions:
1. Grant DOMAIN\myApp_Admin accont a sysadmin server role on SQL server
2. Open SharePoint Power Shell and execute Add-SPShellAdmin <DOMAIN\myApp_Admin> command.
3. Grant DOMAIN\myApp_Admin a db_owner rights to web application Content database that you would like to use for debugging SharePoint 2013 app.
4. Make sure following roles are assigned for SharePoint_Config database
   SharePoint_Shell_Access
   SPDDataAccess
   public
5. Make sure following roles are assigned for SharePoint_Content database
   db_owner
5. Make sure following roles are assigned for SharePoint_AdminContent database
   public