Sunday, September 7, 2014

Missing "Sign in as Different User" option in sharepoint 2013

Workaround : http://siteurl/_layouts/closeConnection.aspx?loginasanotheruser=true (works on some browsers)

Permanent Fix: 

1)  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\welcome.ascx

2) Put this code in welcome.ascx page

<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text=" <%$Resources:wss,personalactions_loginasdifferentuser%>"  
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" 
MenuGroupId="100"   Sequence="100"   UseShortId="true"   />



Thursday, September 4, 2014

Remove and Uninstall a solution

PROBLEM: Once a solution has been added and deployed. Now, I would like to have it removed. But when i execute the install and remove command, I get this error:
The solution "xyz.wsp" has been deployed in the farm. Please retract the deployment before removing the solution.

SOLUTION:
To remove a solution you need to first uninstall it - and that will take a while, in the meantime if you execute the remove command you will get an error that would tell you to hold your horses (in boring robotic gibberish).

This script will do both in sequence and wait for the 'uninstalling' to finish before the 'remove' can execute.  

$s = get-spsolution -identity <WSP filename>.wsp 
uninstall-spsolution -identity <WSP filename>.wsp -confirm:$false

while($s.JobExists) { 
start-sleep -s 10 
}
remove-spsolution -identity <WSP filename>.wsp -confirm:$false

'The Windows PowerShell snap-in'Microsoft.SharePoint.PowerShell is not installed on this machine'

PROBLEM: I had reinstalled Sharepoint Foundation 2013 on win 2008 R2 SP1 and when I opened Sharepoint Management Shell and I got this error:

RESOLUTION: 
To install the dll, run this script in Powershell

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /LogToConsole=true C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\v4.0_15.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Powershell.dll  



Wednesday, August 27, 2014

Can I know my Sharepoint Site's size?

Of course you can, dear!

ONLY CLICKS AWAY - Without using Powershell and stsadm:
1) Through central admin:
Central Admin -> Application Managment -> 'Quotas and Locks' under SiteCollection > Scroll down to the 'Site Quota Information' , you will find the 'Current storage used'
2) Through the site 
Site Actions -> Site Settings -> 'Site Collection Web Analytics reports' under 'Site Actions'  

TYPE AWAY - Using Powershell or STSADM:
1) stsadm:
stsadm - o enumsites -url "http://SiteURL" > c:\sites.txt
The resulting file contains the total size.

2) Powershell
Refer 
http://blogs.technet.com/b/fromthefield/archive/2013/07/25/windows-powershell-script-to-output-site-collection-information.aspx
http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=270 ( its for Sharepoint 2010 but the solution can inspire you to tweak your solution for Sharepoint 2013)



Tuesday, August 26, 2014

Show me the full error!!!

"Yeah! Right... Show me the error! I want it now! Fed up of you sending me chasing after a stupid Co-relation ID!". Do you relate to this desperate call of frustration? Then you have come to the right place.

The error message isnt very helpful. Plus, this error message is ok if you had easy access to the server or atleast someone sends you the ULS log the moment the error occurs. But in the cases that both dont happen, its best you have the full error message displayed, at least till the issue is resolved. 

To enable the whole error message in Sharepoint 2013 just make these two changes to the web.config file:
1) Enable Custom Errors: 
Change to:

<system.web> ...
<customErrors mode="Off" />

2) Enable Call Stack Trace: 
Change To:

<SharePoint>

<SafeMode ... CallStack="true" ... >

</SharePoint>


Check if the error message is now showing as expected.

Doesn't it make you happier? Happy trouble-shooting!

Friday, January 25, 2008

Creating Custom Properties in MOSS 2007 for People Search and Using CAML Queries for Searching

This is an acticle for Creating Custom Properties and Using the QueryEx method in the Search .ASMX webservice to retrieve the results.

Implementation:

The following Web Service was used to retrieve the Employee Details from the Profiler Database.
http://xxxxx(sharepoint%20site)/_vti_bin/Search.asmx
The above Web Service has a Web Method “QueryEx” which upon execution retrieves the results of the Employees from the Profiler Database.

QueryEx Method:

Input: SqlQuery

Output: Dataset of the People Results from the Profiler Database.

Sample Query:

string QueryXMLString= "<QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\"><Query domain=\"QDomain\"><SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats><Context><QueryText language=\"en-US\" type=\"MSSQLFT\">"; QueryXMLString += "<![CDATA[ SELECT FirstName,LastName,Path,OfficeNumber,AccountName,MailStation,CostCenter,JobTitle,WorkEmail,WorkPhone,WorkCountry,Department, SupervisorName,SupervisorID FROM portal..scope() WHERE "; QueryXMLString += "FirstName like '" + '%' + sFirstName + '%' + "' AND LastName like '" + '%' + sLastName + '%' + "' AND"; QueryXMLString += "( (\"SCOPE\" = 'Phone Book') ) ]]></QueryText></Context><Range><StartAt>1</StartAt><Count>100</Count></Range></Query></QueryPacket>";

The above Query returns the results with all the properties(Built-in and Custom) from the Profiler Database.

To make the Custom Propeties Searchable and used in the SQl Statement we have to make the following changes below should be in the Profiler Database.

First Click Sharepoint Service Provider(SSP)under the Sharepoint Services Administration
1) Click on User Pofile and Properties
2) Click View Profile Properties under the section “User Profile and Peoperties”.
3) Click on “New Property” and Create the new Custom Property.

--> First when we create the “Custom Properties” in the Profiler Database we should check the option “Indexed” in the Search Settings Section of the Custom Property.






--> Also in the “Policy Settings” Section Please select the Default Privacy Settings “Everyone”.




--> The run the “Full Crawl” in the Search Settings of the “SSP”.











--> This will enable the Custom Properties Searchable by the Web Services provided by the Sharepoint.

--> We can check the Properties available for Searching by following the below steps.
First Click Sharepoint Service Provider(SSP) under the Sharepoint Services Administration








--> Click the “Search Settings” under the Search Section.
Click on the “Managed Properties” under the Crawl Settings Section.
We will be able to see the “Custom Properties” like “MailStation” etc. on the “Managed Properties” under the Crawl Settings Section.

Tuesday, June 19, 2007

Deploying a Webpart

This article will take you through three ways of deploying a webpart:
METHOD 1: Using a CAB File
METHOD 2: Placing DLL in Site's BIN
METHOD 3: Placing DLL in GAC
So, if we want to deploy a webpart, we first need to create one. For the sake of an example I will explain how to create a terribly simple webpart in Visual Studio 2005.
(I) Create a WebPart
We will create 3 WebPart Libraries for the sake of explination- WebPartLibraryMethod1, WebPartLibraryMethod2, WebPartLibraryMethod3. Each having only one webpart.
1)Create a WebPart Library Project (File->New Project->select Visual C#->select WebPart Library) Lets name the project and solution by the deploment method you chose to demonstrate, so if you are trying method 1, then the name WebPartLibraryMethod1. A WebPart is automatically created at the creation of the project. A WebPart is essentially a pair of files - a class file(.cs) and a Dashboard Web Part file(.dwp). Delete WebPart1.cs and WebPart1.dwp. Right click on the project and Add a Webpart. Name them as per the deployment method you would like to try, for eg, WebPartMethod1.cs . A .cs and a .dwp files of the same name will be created.
Before we proceed any further, ensure that:
i) .cs and .dwp files have the same name
ii) view .dwp file's properties, set 'Build Action' property to 'Content'.
iii) Manifest.xml file has the correct DWP file mentioned in the tag
2)Strong name your assembly. To do this, view the Project's Properties. In the Signing tab, choose a new strong name for the assembly.
3)Build the project.
4)Find the PublicKeyToken of the DLL created. You may use one of the following ways to find it:
METHOD 1:Open Visual Studio Command Prompt and type
sn -T DLL's path
Eg: sn -T "c:\Document and Settings\tingo\Visual Studio 2005\Projects\WebPartLibrary1\WebPartLibrary1\bin\debug\WebPartLibrary1.dll"
OR
METHOD 2:Use Lutz Roeder's Reflector. Install it, then, drag and drop the DLL into it to get the details of the DLL.


(II) Deploy the Webpart
METHOD 1: Using a CAB File
1)Edit the tag in the DWP file
2)Add a CAB Project to the Project's solution. (File->Add->New Project->Select Other Project Types->select Setup and Deployement-> select CAB Project)
3) Right click on the CAB Project, select Add,select Project Output. From the Project Output Group dialogue box, select both, Primary Output and Content Files. Click OK.
4)Rebuild the whole solution. This creates a CAB file in the CAB project's BIN.
5)Copy the CAB file to a location on the Sharepoint server, say, C:/
6)In the Command Prompt, navigate to the folder where stsadm.exe is located, which is, c:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/12/BIN. Now, type:
ststadm -o addwppack -globalinstall -force -filename CAB file's pathc
Eg: ststadm -o addwppack -globalinstall -force -filename "c:\WebPartLibCab.CA"

-END OF METHOD 1- Now, you may use this webpart in Sharepoint as you would any other. Check out for your self- Modify a site, Add a Webpart, you will find your webpart in the Webpart Dialogue box under Miscellaneous!

METHOD 2: Placing DLL in Site's BIN
1)Place the DLL in the _app_bin of the site.(To find its location, use the inetmgr)
2)Update the web.config file of the site with a tag for this DLL, as follows:
3)Reset IIS
4)Go to the Sharepoint site, go to Site Setting, under Galleries, select Webparts. Click New, select the webpart we just created and Add.
-END OF METHOD 2- Now you can use the webpart

METHOD 3: Placing DLL in GAC
1)Place the DLL in the GAC (c:\windows\assembly\)
2)Update the web.config file of the site with a tag for this DLL, as follows:
3)Reset IIS
4)Go to the Sharepoint site, go to Site Setting, under Galleries, select Webparts. Click New, select the webpart we just created and Add.
-END OF METHOD 3- Now you can use the webpart