Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Tuesday, September 28, 2010

Show communicator status in your custom application pages

When ever we show a username in a custom application page or in a custom web part, adding that small presence aware icon before the user name will be a value addition to the end users which allows to see the person's availability.

An ActiveX control called NameCtrl in Name.Dll is responsible to retrieve the user status and rendering.

Use the following snippet, get the string and render it on your custom page to make the presence aware work for you. Ensure Ows.Js is referenced in your master page, this javascript is responsible for instantiating the ActiveX control and rendering.

public static string GetIMStatusForUser(string personEmail, string personName)
{
string statusJS = String.Format("<span><img border=\"0\" height=\"12\" width=\"12\" src=\"/_layouts/images/blank.gif\" onload=\"IMNRC('{0}')\" id=\"IMID\"
ShowOfflinePawn=1><a href=\"mailto:{0}\">{1}</a></span>",
personEmail,personName);
return statusJS
}

Wednesday, September 1, 2010

Unlocker : Error debug privileges

If the user doesn't have permission for remote debugging,Unlocker  will fail with the following error message

Error Debug privileges

Provide Debug privileges for the user in the target machine to satisfy Unlocker

Start -> Run -> "secpol.msc" then click ok
Expand "Local Policies" in left pane
click the "User Rights Assignments" folder
On the right hand screen double click "Debug Programs"
Click the "Add User or Group" button
Click the "Advanced" button
Click the "find now" button
select your "user logon name" and then click the "Ok" button



Changes will take effect after a logoff or a reboot. 

Thursday, June 17, 2010

Hide sign in link for anonymous users in SharePoint internet facing sites

A frequent request when you enable anonymous access to any of your SharePoint zone is to hide the "Sign In" hyper link which comes in top right corner of the page. Probably the business might have a request to have an intranet site for all authenticated users and an anonymous site for their customers, so showing a "sign in" link is irrelevant by all means.
Let try eliminating this link in somewhat supported way.

Anatomy of the control
This link comes from user control called welcome.ascx in 12hive\TEMPLATE\CONTROLTEMPLATES, this user control has a feature menu template which is responsible for rendering the menu containing "sign in as different user" and "Sign out" options

Rendering of Feature Menu Template


Scroll towards the end of the file you will find the following section

<SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin" ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true
Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" />

This application link control is responsible for rendering the "Sign in" control

Take a look at the control tag for its implementation, its visible attribute is marked as false, this will become visible only if the user is not authenticated and the site has anonymous access enabled.
Steps to remove sign in link
  1. Create a new folder under 12hive\TEMPLATE\CONTROLTEMPLATES say 12hive\TEMPLATE\CONTROLTEMPLATES\Foo
  2. Copy the welcome.ascx to this Foo folder (lets stick to best practice of not touching the OOB files).
  3. Comment this ApplicationPageLink section in this copied file under \CONTROLTEMPLATES\Foo

<!--<SharePoint:ApplicationPageLink runat="server" id="ExplicitLogin"
ApplicationPageFileName="Authenticate.aspx" AppendCurrentPageUrl=true
Text="<%$Resources:wss,login_pagetitle%>" style="display:none" Visible="false" /> -->

4. Open your custom master page and modify the mapping to our new user control as below

<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Foo/Welcome.ascx" %>

There you go .. . Do an iisreset and refresh the anonymous page

Less custom code, less bugs and more solid solutions.


Wednesday, June 16, 2010

Compare context menu in Winmerge

I heavily use Beyond compare to compare and merge files. I personally like the BC's context menu option "Select left side to compare" and "Compare to xxx" But one fine day the trial version expired and the only other alternate is WinMerge.


Winmerge also has this option buried deep under the options dialog box.
Open winmerge.exe from C:\Program Files\WinMerge\winmergeU.exe and select Edit-> options


Here you go with the Winmerge's compare To option enabled in context menus

Monday, November 16, 2009

Where is Windows Server 2008 SP1 ?

While preparing a Windows server 2008 virtual machine and as usual I was just looking up Microsoft.com for patching my newly installed operating system(to get the bug fixes).

Interestingly I was not able to find Windows Server 2008 SP1, there is only SP2 available and came to know that the initial OS installation includes the SP1.

FAQ Section of Windows Server 2008 SP1 clarifies the doubt,Following text taken from the FAQ

Are there any prerequisites for SP2?

You must have Windows Vista with SP1 or Windows Server 2008 installed on your computer before installing Service Pack 2. (Windows Server 2008 shipped with Service Pack 1 included.)

Screen shot after the clean installation of Windows server 2008



Thursday, September 17, 2009

How to find the site template used on a Site ?

Some times I stumble upon some heavily modified sites to find out the site template(Team site/Blank site etc) used for provisioning that instance. That's quite easy using the object model but I wondered is it possible through some out-of-the box tool or UI's

Recently came across the WSS RPC methods It has a function called GetProjSchema which does this magic

Authenticate with the web application

Remove all strings after the site name from the address bar and append the following string

/_vti_bin/owssvr.dll?Cmd=GetProjSchema

So if you have application as Foo and it has a site called PWA then the URL might be looking like this

http://Foo/PWA/_vti_bin/owssvr.dll?Cmd=GetProjSchema

GetProjSchema requests the CAML Schema for a Web site, this is a blend of ONET.XML for that specific site definition and some resources which are related to that provisioned site instance. This CAML schema is cached in IIS, so we've retrieved this cached version to find out the site template

This gives more details than required but we are now interested in the site template used, look at the first line "Project Title=". This is the current site template being used

A sample screen snap


Anything which comes OOTB capable of solving real world problems is good. Exploit the rendered CAML . .. .

Thursday, August 27, 2009

Including quotes in verbatim strings

As we all know C# supports two types of strings: regular and verbatim strings. Escape sequence character such as backslash is not processed within this verbatim string sequence except quote-escape-sequence("). I recently stumbled across this C# basic string rule


So to encode a xml fragment like this

string s="[formbody xmlns="http://www.Foo.com/FormBody"][/formbody]"

We should have to write as follows using verbatim character and Quote escape sequence

string s = @"[FormBody xmlns=""http://www.Foo.com/FormBody""][/FormBody]";

but C# handles this quote-escape-character as regular escape sequence internally


So beware while using verbatim strings and escape sequences altogether especially in cases of handling XML/HTML strings in C# code

For more Check the C# language Specification


Monday, July 20, 2009

FIX - Firefox 3.5.0 load time delay fixed

Firefox 3.5.0 didn't perform as it promised earlier, especially on loading the browser first time when you click from the start menu or from the quick launch bar. It took approximately around a minute to load the application. Practically no user will wait for this much long time and I ignored using Firefox for day-to-day use.

Finally Mozilla came up with a fix in Firefox 3.5.1 check out the release notes. So moral of the story is upgrade your Firefox to 3.5.1 and get the blazing speed.

Sunday, October 5, 2008

How to compact Virtual hard drives?

When we develop in our virtualized dev environment, the virtual hard disk will expand dynamically in size. The problem is they don't compact automatically when we clean-up the VHD's. steps to reduce the VHD in size

1. Remove all unwanted files in temp locations or use CCleaner to remove all unwanted files.
2. Uninstall all programs which are unused in the dev environment.
3. Defrag the disk by using the system defragmenter.
4. select Capture ISO Image from CD menu and browse to the Virtual PC additions
directory
5. Location is %ProgramFiles%\Microsoft Virtual PC\Virtual Machine Additions by default.
6. Mount Virtual Disk Precompactor.iso. The precompactor will start automatically.
7. Once it's done , shut down the Virtual Hard disk.
8. Select the VPC from the Virtual PC console. Click on the settings button and select the Harddisk1 from the left pane.
9. Click over the "Virtual Disk Wizard" button and click next in the wizard.
10. select Edit existing disk, next choose the compact option - this can take a while to complete

For more info KB888760 How to prepare a Virtual Server 2005 virtual hard disk file to send to Microsoft Product Support Services

Wednesday, September 17, 2008

SharePoint development VM loves IISReset

When we develop application pages or custom web part development in SharePoint. This requires a lot of IISreset for each and every bit of change in the assembly when we are going to deploy these modified binaries GAC.

IISRESET takes a lot of time instead of that if we recycle the required application pool which is associated to our IIS web application, this will save atleast a minute of dev effort.

This recycling process can be automated by using the following OOB VB script

cscript.exe iisapp.vbs /a SharePointAppPool /r

or
cscript.exe iisapp.vbs /p [Process ID] /r

[Process ID] : This can be obtained just by executing iisapp.vbs in the command line. This will list all the application pools with their process ids

Get more info about IISapp.vbs from Microsoft Technet library

Do you want to recycle all the application pools in your IIS ?

Save the following the VB script to vbs file and replace the MachineName with your Dev machine's name

Set locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = locator.connectserver("MachineName", "root/MicrosoftIISv2")
Set APCollection = Service.InstancesOf("IISApplicationPool")
For Each APInstance In APCollection
APInstance.Recycle
Next

Friday, September 5, 2008

Retrieving the password for IUSR & IWAM accounts

IIS provides  a script file called adsutil.vbs to obtain or set the password for IUSR/IWAM accounts in IIS metabase. Just adding this tip not to forget in future.

More details : http://support.microsoft.com/default.aspx?scid=kb;en-us;297989

Wednesday, August 13, 2008

A CAML View of a SPList

Want to get some Guid's of a list or some of its site column Guid's while developing features.

http://Foo/Library/_vti_bin/owssvr.dll?Cmd=ExportList&List={DA45FCA4-2B2C-4532-8E89-65FF6813F057}

This will emit the information as CAML/XML there we can find all the information.

Naivgate to Web part maintenance page

To delete a closed web part in a web part page , we need to navigate to the maintenance page but there is no links pointing to the page, So force the web part page url by appending ?contents=1 to the query string will launch the page

Sample:
http://www.foo.com/default.aspx?contents=1