Sunday 28 September 2014

Redirect aspx website in IIS using C# code.

My Scenario:

  I want to access my domain www.myexample.com/in, when I try to browse my sub domain site  www.myexample.in.

Solution:

    I tried the below  code in my default.aspx page,

<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.myexample\.in
RewriteRule (.*) http://www.myexample.com/in/$1 [R=301,L]

The direction is works fine.

Saturday 6 September 2014

Your Certificate request was denied. "Denied by Policy Module 0x80070576, Active Directory Certificate Service could not find required Active Directory Information"

Error:

    Your Certificate request was denied

    Your request ID is <>. The disposition message is, "Denied by Policy Module 0x80070576, Active Directory Certificate Services could not find required Active Directory Information".



Scenario:

    When I tried to download the certficate from the Active Directory Certificate Server, I got the above error.

Solution:

    When I checked the time for the both DC and CS server both are different. My CS server was 1 hour ahead from the DC. I adjusted the time and the certificate downloaded fine.

Friday 5 September 2014

Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unnecessary system resources in SHAREPOINT server

Error :

Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unnecessary system resources.
To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'. The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account.
 Additional Data:
 Current default super user account: [MachineName]\system SharePoint 2010 is hosted on this machine.


Scenario :

The IIS APPPool account does not have access permission for the DB/tables and display the result.(in my scenario, SQL Server (SSRS) Reports not accessible).

Solution :

I gave DB_Owner permission for the user APPPool account to the DB.

Wednesday 16 July 2014

Get Assembly Name of SP Timer Job

To Get Assembly (.dll) name of particular SP Timer Job use the below command,

Get-SPTimerJob -WebApplication "http://<SPSite>:<Port>" -Identity "<Timer Job Name>" | select Name, DisplayName,TypeName | Format-List

Friday 11 July 2014

The URL ‘[url]‘ is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web in SharePoint

My Work Env:

 I got the error "The URL ‘[url]‘ is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web"  in SharePoint 2010. The site was working fine, but after few days the SharePoint site got the error.

    In my scenario, the lookup filed does not give this error, because i don't use any lookup field in SP env.
(for ref : http://bernado-nguyen-hoan.com/2011/03/22/sharepoint-evil-1-the-url-url-is-invalid-it-may-refer-to-a-nonexistent-file-or-folder-or-refer-to-a-valid-file-or-folder-that-is-not-in-the-current-web/ ).

  Root Cause:
   My SharePoint site's DB machine has 0bytes free memory.

Solution:
   I freed some space, then site works as normal.

The server encountered an error processing the request. See server logs for more details in (.svc) WCF Service

My Work env:

When I tried to access the .svc file hosted in IIS, I got the below mentioned error

The server encountered an error processing the request. See server logs for more details.

I didn't get any other clue about this error.

Solution:

I added the line in .svc.cs,

config.UseVerboseErrors = true; in InitializeService() function.

Now I got a much clearer error message on the client side.

Saturday 21 June 2014

Could not load file or assembly 'Microsoft.SharePoint.Client.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified in Office 365

My Work env:

In Office 365, I have created an app with Search Service Application. When I add the app in the Office 365 site I got below error,

Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.SharePoint.Client.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SharePoint.Client.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

Source Error:
 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.SharePoint.Client.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' could not be loaded.

Solution:
Change the specific version is true for 'Microsoft.SharePoint.Client.Search' in DLL Properties.



Basic Command Scripts

To move File with Rename with Current Date and Time:  

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do move "C:\Users\logan\Desktop\wf1\my.log"  "D:\my_%%e%%f%%g_%Time:~0,2%%Time:~3,2%%Time:~6,2%.log".

Create Event Log source using CMD:

   1. eventcreate /T ERROR /ID 900 /L APPLICATION /SO "Bauer" /D "Log for Bauer Application"
  2. eventcreate /ID 192 /L APPLICATION /T INFORMATION  /SO "HSEx
tranet555 " /D "Log for HS Extranet Application"

Get assembly files from GAC using PowerShell:

dir C:\Windows\Assembly -Recurse -Filter "VendorName*.dll" | foreach { copy $_.FullName C:\Temp }

Wednesday 7 May 2014

Change outgoing Email settings in SharePoint 2013

I have configured Outgoing Email settings in SharePoint 2013. But the FROM email id in the mail shows another Email ID, what actually I have configured in Outgoing Email settings in SharePoint Central Admin.

Root Cause :

    The web application which triggers the mail has different email ID what we configured in the SP Central Admin.

PowerShell cmd to check OutboundMailSenderAddress,

 (Get-SPWebApplication http://SPWebApp).OutboundMailSenderAddress

Check for both, web app and Central Admin URL.

Solution:

I have updated the OutboundMailSenderAddress mail address using SP Management Shell,

$webApp = Get-SPWebApplication "http://SPWebApp"

$webApp.OutBoundMailReplyToAddress = "no-reply@suglog4.net"

$webApp.OutboundMailSenderAddress = "sharepoint2013@suglog4.net"

$webApp.IncomingEmailServerAddress = "suglog4Mail"

$webApp.Update()

Note : If you have more than one WFE and APP server run the above script line for all the servers and check whether the OutboundMailSenderAddress user has updated.

Now check the both the SP Central Admin and  Web App OutboundMailSenderAddress user's are same.

PowerShell cmd to check,

 (Get-SPWebApplication http://SPWebApp).OutboundMailSenderAddress

Cannot connect to the configuration database



My Issue:

 Cannot connect to the configuration database

1. SQL services is in start state, but Restarted the SQL services
2. Checked AppPool in IIS and restarted all the web sites and AppPools are looking good. But still got same error. 

3. Checked the Event viewer it shows the below error.

Cannot connect to SQL Server. machine name not found. Additional error information from SQL Server is included below.Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

4. Tried to Login SQL using Windows authentication login failed and got response  "Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

5. But SA account Login successfully.

Solution:

Checked DC it was shutdown. Switched on the DC and everything back normal

Tuesday 1 April 2014

The imported project "Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Silverlight 4.0 Projects not open in the Silverlight 5.0 installed machine and shows the below error
Error :
The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.



Solution:
In Silverlight V4.0 path has only  Microsoft.Silverlight.CSharp.targets file in the path, 
C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v4.0

but in Silverlight V5.0 has (C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0) below files,
1. Microsoft.Ria.Client.targets
2. Microsoft.Silverlight.Build.Tasks.dll
3. Microsoft.Silverlight.Common.targets
4. Microsoft.Silverlight.CSharp.targets
5. Microsoft.Silverlight.VisualBasic.targets
6. XamlServices.dll
7. zlib114.dll

I copied all the Missing files except  Microsoft.Silverlight.CSharp.targets  and pasted in v4.0 path. Now projects loads without an issue.

Saturday 15 March 2014

Archieve/Backup Visual SourceSafe file using CMD


@ECHO OFF
@TITLE Backing up source safe databases
FOR /F "tokens=2-4 delims=/ " %%i IN ('date /t') DO SET DATE=%%k%%j%%i
FOR /F "TOKENS=1-2 DELIMS=: " %%I IN ('time /t') DO SET TIME=%%I%%J
FOR /F "TOKENS=2 DELIMS= " %%K IN ('time /t') DO SET AMPM=%%K
"C:\Program Files\Microsoft Visual SourceSafe\ssarc" -d- "E:\Today.ssa" $/ "-sE:\Vss-Projects" -yadmin,pass@word1
@ECHO Finished backups


Here,
  
C:\Program Files\Microsoft Visual SourceSafe\ssarc is SourceSafe Archieve application (ssarc.exe) path
E:\Today.ssa - Backup File Location and Name
E:\Vss-Projects - Current Srcsafe stored Location.
admin and pass@word1 is credential for the VSS admin who has permission to backup and restore. 

Add a crawled property in SharePoint 2013 with sortable/Refinable using Powershell



For Sortable:

New-SPEnterpriseSearchMetadataCrawledProperty -Category SharePoint -IsNameEnum $false -Name "ows_MyCrawledProperty" -PropSet 00130329-0000-0130-c000-000000131346 -SearchApplication "Search Service Application" -VariantType 0

New-SPEnterpriseSearchMetadataManagedProperty -Name "MyCrawledProperty" -SearchApplication "Search Service Application" -Type 1 -Queryable $true -Retrievable $true

$cp = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication "Search Service Application" "ows_MyCrawledProperty"

$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication "Search Service Application" -Identity "MyCrawledProperty"

$mp.sortable= $true

$mp.update

New-SPEnterpriseSearchMetadataMapping -SearchApplication "Search Service Application" -CrawledProperty $cp -ManagedProperty $mp


For Refinable:

New-SPEnterpriseSearchMetadataCrawledProperty -Category SharePoint -IsNameEnum $false -Name "ows_MyCrawledProperty" -PropSet 00130329-0000-0130-c000-000000131346 -SearchApplication "Search Service Application" -VariantType 0

New-SPEnterpriseSearchMetadataManagedProperty -Name "MyCrawledProperty" -SearchApplication "Search Service Application" -Type 1 -Queryable $true -Retrievable $true

$cp = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication "Search Service Application" "ows_MyCrawledProperty"

$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication "Search Service Application" -Identity "MyCrawledProperty"

$mp.Refinable= $true

$mp.update

New-SPEnterpriseSearchMetadataMapping -SearchApplication "Search Service Application" -CrawledProperty $cp -ManagedProperty $mp



Error: Cannot generate SSPI context in SQL server

                         

 My Scenario: 
          I Got error "Cannot generate SSPI context" in SQL, when I access
(machine1) Destination machine’s SQL instance from (machine2)Source Machine SQL instance.
 It works fine when I access using "sa" account but it happened only in Domain account.

Solution: 
 Check the below details,

1. The Domain Controller is On and accessible by the both SQL computers.
2. Time and TimeZone is synched with Domain Controller.
if not, run the below comments in cmd prompt to reset the time in both computers
   net stop w32time
   net start w32time