Joseph Michael Pesch
VP Programming

SMTP Hosting Service

by 28. July 2013 08:45



jQuery Document.Ready Doesn't Work with ASP.Net UpdatePanel

by 27. July 2013 21:47

When using an ASP.Net UpdatePanel you may need to use the PageRequestManager to bind functions that would otherwise be bound on the page load or jQuery Document.Ready function (see below).  Link to blog article on this topic: 

$(document).ready(function() {
    // bind your jQuery events here initially

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_endRequest(function() {
    // re-bind your jQuery events here


ASP.Net | JQuery

A Guide to Designing and Building RESTful Web Services with WCF 3.5

by 22. July 2013 07:09

Excerpt from this article:

From the point of view of REST, a “real” Web service is a service designed to embrace the “Web” from the ground up. The Web has become the most successful distributed computing platform ever developed, thanks to years of investment and widespread usage. The Web platform includes concepts that you’re probably already familiar with like URIs, HTTP, and common data formats like XML, RSS/ATOM, and JSON. Ultimately, services that embrace these core concepts will immediately derive the valuable benefits they provide.

REST defines an architectural style based on a set of constraints for building things the “Web” way. REST is not tied to any particular technology or platform – it’s simply a way to design things to work like the Web. People often refer to services that follow this philosophy as“RESTful services.” In this whitepaper, we’ll cover the fundamental REST design principles and show you how to build RESTful services with Windows Communication Foundation (WCF), the WCF REST Starter Kit, and ADO.NET Data Services.



Sharepoint 2010 Development on Windows 7 Virtual Machine

by 22. July 2013 07:01

Sharepoint 2010 Registry Entries

I recently installed a development machine with the necessary tools to perform SharePoint development on a Windows 7 64bit virtual machine.  The machine was then used as a master for a set of 7 virtual desktop developer workstations.  The issue; however, was that the inital intallations created several registry entries that referenced the original machine name.  This rendered the Sharepoint environment broken on all the virtual desktops (as each one had a different unique machine name).  To resolve this, I went back through the registry on the master and change the original machine name to "LOCALHOST" virtual name on all the following registry entries.  NOTE: The initial symptom manifest itself initially when opening the browser and attempting to browse to the local sharepoint site (in this case htt://localhost).  The page threw the follwing error: "Cannot connect to the configuration database."  Upon reviewing the log Sharepoint files (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS\...) I noticed the original machine name in the failed connection attempt log entry.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\LauncherSettings\LoadBalancerUrl
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Applications\c0e071e1-533e-457a-8a61-8a86a6b78dcd\Gather\Portal_Content\ContentSources\0\StartPages\0\URL
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Applications\c0e071e1-533e-457a-8a61-8a86a6b78dcd\Gather\Portal_Content\ContentSources\0\StartPages\1\URL
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Applications\c0e071e1-533e-457a-8a61-8a86a6b78dcd\ResourceManager\ (several entries)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Applications\fd2e5092-25e3-46cf-8fc6-d62c85334b3d\Gather\Search\ContentSources\0\StartPages\0\URL
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Applications\fd2e5092-25e3-46cf-8fc6-d62c85334b3d\ResourceManager\ (several entries)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDB\dsn
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\CentralAdministrationURL


Sharepoint | Virtual PC | Windows

Sharepoint 2013 Development Using Visual Studio 2012

by 16. July 2013 13:14

Here is a good article on setting up Visual Studio 2012 to allow development of Sharepoint 2013 applications.


ASP.Net | Sharepoint

jQuery Invisible Dialog - Borderless with Transparent Background

by 1. July 2013 07:03

Here is some code to remove the titlebar from a jQuery dialog and also remove the borders and make the background transparent (effectively making the dialog itself invisible so only the actual content of the dialog is visible.

var $obj = $('selector');
$obj.dialog({ });
  .css("border", "0 none")
  .css("background", "transparent")



Team Foundation Server (TFS) Building Project with External Assemblies

by 27. June 2013 08:47

This approach to fix the issue with using external assemblies (i.e. assemblies not in the project folder structure).  In this example the project references the "Encompass" assemblies from the "C:\Program Files (x86)\Encompass" folder.  I wanted to use the program file reference so it’s easy to upgrade SDK; however, Visual Studio Project always have relative paths which doesn’t get resolved in TFS Build.  To resolve this I have add new registry key for the Encompass folder path on the TFS build server so that it looks into this location when it compiles any project.  Now I don’t need to change the project file. 

Registry key: HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > .NET Framework > AssemblyFolders

Add new key (in this case "Encompass") and then update the "(default)" string value to be the path to the assemblies (in this case "C:\Program Files (x86)\Encompass").


ASP.Net | Visual Studio | TFS

jQuery Dialog Disable Ok Button

by 24. June 2013 13:43

In some cases depending on the usage you may have a jQuery dialog open after the user clicks the Ok button; however, you may want to disable the button to prevent the user from double-clicking it.  Here are a couple of methods to achive this typ of behavior.  

Just disable the Ok button:

$(".ui-dialog-buttonpane button:contains('Ok')").attr("disabled", true).addClass("ui-state-disabled");

Remove all buttons and replace with a processing indicator:

     title: 'Sample Dialog', 
     modal: true, 
     buttons: { 
       'Cancel': function() { $(this).dialog('close'); },
       'Ok': function() { $('.ui-dialog-buttonpane').html('<div style="width: 100%; text-align: center; padding: 20px; font-size: 20px; background: url(processing.gif) no-repeat;">Processing please wait...</div>'); 



C# Windows Service to Log User Unlocking/Locking Computer

by 20. June 2013 08:09

Windows event logs will typically capture user login/logout activity; however, it does not capture user unlocking/locking their computer (which quite often is the more frequent activity).  This C# code will run as a Windows service and add Information entries into the Windows Application log accessible via the system Event Viewer.  Currently the code currently has an error in implementing "System.Security.Principal.WindowsIdentity.GetCurrent().Name" as an attempt to log the user name performing the activity; however, that is actually simply logging the user name that the Windows service is running as.  In a future update I plan to fix this issue and add the actual user name to the log entry.

 UserLockUnlockProfiler.zipx (41.86 kb)

Links regarding service interacting with user desktop:

Main Service Code:

using System;
using System.Diagnostics;
using System.Management;
using System.ServiceProcess;

namespace ULUPSvc
    public partial class ULUPSvc : ServiceBase
        public ULUPSvc()
            this.CanHandleSessionChangeEvent = true;

        public void LogEvent(string msg)
            msg += " " + DateTime.Now.ToString();
            ManagementScope ms = new ManagementScope("\\\\.\\root\\cimv2");
            ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_ComputerSystem");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, query);
            foreach (ManagementObject mo in searcher.Get())
                msg += " (" + mo["UserName"].ToString() + ")";
            EventLog eventLog = new EventLog();
            eventLog.Log = "Application";
            eventLog.Source = "ULUPSvc";
            eventLog.WriteEntry(msg, EventLogEntryType.Information);

        protected override void OnSessionChange(SessionChangeDescription changeDescription)
            switch (changeDescription.Reason)
                case SessionChangeReason.SessionLogon:
                case SessionChangeReason.SessionLogoff:
                case SessionChangeReason.SessionLock:
                case SessionChangeReason.SessionUnlock:

        protected override void OnStart(string[] args)
            // Make sure we have our application in the event log.
            if (!EventLog.SourceExists("ULUPSvc"))
                EventLog.CreateEventSource("ULUPSvc", "Application");

        protected override void OnStop()





SQL Statement to View Connected Login Authentication Schema in Use (i.e. SQL, NTLM, Kerberos, etc.)

by 15. April 2013 12:45
The following is a SQL statement that will return a list of active connections and the login authentication schema being used by the connection.  This is useful in validating that connections are using the expected protocol. 
sys.dm_exec_connections c
inner join
sys.dm_exec_sessions s
on c.session_id = s.session_id


SQL Server

Uploadify Issue with IE9 Button Not Triggering Browser to Upload

by 13. April 2013 23:18
Suffering issue wtih IE9 and Uploadify where the button that usually triggers the browse for file dialog does nothing.  It works if I switch to compatability mode but does nothing in standard mode.  I found some updated code below that fixes the issue, just replace the existing code in the jquery.uploadify.js and jquery.uploadify.min.js files.
SWFUpload.prototype.getFlashHTML = function () {
  // Flash Satay object syntax:
  var obj = ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">'].join(""),
params = [
'<param name="wmode" value="', this.settings.button_window_mode, '" />',
'<param name="movie" value="', this.settings.flash_url, '" />',
'<param name="quality" value="high" />',
'<param name="menu" value="false" />',
'<param name="allowScriptAccess" value="always" />',
'<param name="flashvars" value="', this.getFlashVars(), '" />'
  if ( > -1) {
    obj = ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="', this.movieName, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">'].join("");
    params += '<param name="src" value="' + this.settings.flash_url + '" />';
  return [obj, params, '</object>'].join("");



Sharepoint - User Profile Synchronization Proccess

by 9. April 2013 10:52

When the user information is synchronized from Active Directory (AD) into Sharepoint there are two basic processes. 

First, User Profile Service Application running under the Sharepoint Services on Server is what actually imports data from AD into Sharepoint.  This can be customized to select specific AD attributes and can also be configured to export data back from Sharepoint to Acitve Directory.  This could be useful if you want to allow Sharepoint users to update selected attributes directly in Sharepoint and publish them back to Active Directory.  You can view the current status of an active synchronization by using the Forefront Identity Manager (located at [InstatllationDrive]:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell\miisclient.exe).  The Sharepoint Service relies on the "Forefront Identity Manager Service" which must also be running on the Sharepoint server that is running the synchronization service.

That process simply creates, updates and deletes the records in the Sharepoint User Database by inspecting the current state of Active Directory.  To have the information visible in the Sharepoint People search and liked visually to organizational heirarchy it must also be propogated into the corresponding Sharepoint content databases.  That portion of the process occurs through the User Profile Sync Timer Job (running under the Sharepoint Timer service) which typically runs at the top of each hour.

IMPORTANT NOTE: If you use the People Picker in Sharepoint to locate user it will locate users directly in Active Directory (i.e. even if they have not been synchronized or setup in Sharepoint previously).  If you then add a user to a library, list, etc. (i.e. grant them permissions, add to a group, etc.) they Sharepoint will create a user stub record in the User Database with minimal data (basically just the user id and guid).  Next time the synchronization process runs it will update all the additional user attributes based on how the service is configured.  In my case the synchronization process was failing so there was some confusion as to how some users were getting into the Sharepoint environment with minimal data (i.e. they were getting added when they were granted permissions to resources in Sharepoint).

A couple of maintenance items that can help if these processes start failing:

1) Clearing the User Profile Sync Table - Over time the data in this table will get corrupted specifically when dropping and attaching databases this is a known issue.  In order to see a list of the entries you can use the listolddatabases commande below.  To clean up the corrupted data you can run the deleteolddatabases command below which will delete all entries that have not been successfully updated since 1 day ago (i.e. the last parameter is the number of days since last update).

STSADM -o sync -listolddatabases 0
STSADM -o sync -deleteolddatabases 1

2) Clear the configuration cache on the servers in the Sharepoint server farm:

To resolve this issue, clear the file system cache on all servers in the server farm on which the Windows SharePoint Services Timer service is running. To do this, follow these steps:
  1. Stop the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click Windows SharePoint Services Timer, and then click Stop.
    3. Close the Services console.
  2. On the computer that is running Microsoft Office SharePoint Server 2007 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
  3. In Windows Explorer, locate and then double-click the following folder:
    Drive:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\GUID
    • The Drive placeholder specifies the letter of the drive on which Windows is installed. By default, Windows is installed on drive C.
    • The GUID placeholder specifies the GUID folder.
    • The Application Data folder may be hidden. To view the hidden folder, follow these steps:
      1. On the Tools menu, click Folder Options.
      2. Click the View tab.
      3. In the Advanced settings list, click Show hidden files and folders under Hidden files and folders, and then click OK.
    • In Windows Server 2008, the configuration cache is in the following location:
  4. Back up the Cache.ini file.
  5. Delete all the XML configuration files in the GUID folder. Do this so that you can verify that the GUID folder is replaced by new XML configuration files when the cache is rebuilt.

    Note When you empty the configuration cache in the GUID folder, make sure that you do not delete the GUID folder and the Cache.ini file that is located in the GUID folder.
  6. Double-click the Cache.ini file.
  7. On the Edit menu, click Select All.
  8. On the Edit menu, click Delete.
  9. Type 1, and then click Save on the File menu.
  10. On the File menu, click Exit.
  11. Start the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click Windows SharePoint Services Timer, and then click Start.
    3. Close the Services console.
    Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
  12. Make sure that the Cache.ini file has been updated. For example it should no longer be 1 if the cache has been updated.
  13. Click Start, point to Programs, point to Administrative Tools, and then click SharePoint 3.0 Central Administration.
  14. Click the Operations tab, and then click Timer job status under Global Configuration.
  15. In the list of timer jobs, verify that the status of the Config Refresh entry is Succeeded.
  16. On the File menu, click Close.
Original link to these clean up steps:



Image Sliders

by 31. March 2013 00:35




Determine Authentication Scheme on SQL Server

by 22. March 2013 14:12

Below is a TSQL statement that will return the current authentication scheme running on your SQL server instance.

SELECT net_transport, auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@SPID;


SQL Server

Microsoft Fix It - Clean Removal Tool Replacement for MSICUU2.exe

by 24. February 2013 09:13

Some times when a software becomes corrupted and you attempt to uninstall/reinstall the software it may be in left in a bad state where it is unusable, leaving you with the only option to reformat your hard drive to reinstall your operating system or attempt to manually fix/unistall which can be very tedious and potentially error prone leaving your system in even a worse state.  The Windows Installer Clean Up tool developed by Microsoft "MSICUU2.exe" was a free and very useful tool to help fix these type of program removal/reinstallation issues.  However, Microsoft decided to retire this tool in 2010 and they have replaced it with another tool called “Microsoft Fix It” which is a progam install and uninstall utility that supports both 32-bit and 64-bit of Windows including Windows 7.  The tool can be run directly from the Microsoft web site; or, it can be downloaded and loaded onto a flash drive, CD, etc. to run locally on an affected machine.

In my case I had Symantec anti-virus software installed and attempted to remove it using the standard Windows Add/Remove Programs from the Control Panel.  However, my uninstall froze in the middle and left my PC in a state where it was gone from the Add/Remove Programs list but not fully removed from my PC.  Worse yet whenever I right-clicked on folders it would prompt me with a series of dialog boxes about trying to install Symantec and can't install.  I was able to successfully remove it using the Microsoft Fix It tool.

Download the tool directly from the Microsoft site:



ASP.Net Security Create New User Account Based on Existing User Account

by 1. February 2013 07:39

This SQL script will create a new ASP.Net user account using an existing user account as the basis.  The new user account will have the same password and roles as the existing user account.  Also included at the end of the main script is a script to change a user account password to a known defualt (e.g. Password1234).

Script to replicate user:

  @ExisitingUserName varchar(50)
, @ExisitingUserEmail
, @OldUserID uniqueidentifier
, @UserID uniqueidentifier
, @Email varchar(50)
, @UserName varchar(50)
, @DeleteIfExists bit

  @UserID = newid()
, @Email = ''
, @UserName = ''
, @DeleteIfExists = 0
, @ExisitingUserName = 'EXISTING_USER_NAME_HERE'
, @Email
, @UserName

select @OldUserID = UserID 
from dbo.aspnet_Users 
where UserName = @UserName

if @DeleteIfExists = 1 begin

delete from dbo.aspnet_UsersInRoles
where UserID = @OldUserID

delete from dbo.aspnet_Membership
where UserID = @OldUserID

delete from dbo.aspnet_Users 
where UserName = @UserName


insert into dbo.aspnet_Users
, @UserID
, @UserName
, lower(@UserName) /* LoweredUserName */
, null /* MobileAlias */
, 0 /* IsAnonymous */ 
, getdate() /* LastActivityDate */
from dbo.aspnet_Users
where UserName = @ExisitingUserName

insert into dbo.aspnet_Membership
, @UserID
, Password
, PasswordFormat
, PasswordSalt
, MobilePIN
, @Email
, @Email
, PasswordQuestion
, PasswordAnswer
, IsApproved
, IsLockedOut
, getdate() /* CreateDate */
, getdate() /* LastLoginDate */
, getdate() /* LastPasswordChangedDate */
, '1/1/1754 12:00:00 AM' /* LastLockoutDate */
, 0 /* FailedPasswordAttemptCount */
, '1/1/1754 12:00:00 AM' /* FailedPasswordAttemptWindowStart */
, 0 /* FailedPasswordAnswerAttemptCount */
, '1/1/1754 12:00:00 AM' /* FailedPasswordAnswerAttemptWindowStart */
, Comment
from aspnet_Membership
where Email = @ExisitingUserEmail

insert into dbo.aspnet_UsersInRoles
select @UserID, RoleID
from dbo.aspnet_Roles

Script to change password:

update dbo.aspnet_Membership 
set PasswordSalt = 'dArJQD4e4upwMyqCSl9iNA=='
, Password = '1mAUj77CySFAtqlfInt4UFOznAc=' /* Password1234 */
where UserId = 
  select UserId 
  from dbo.aspnet_Users 
  where UserName = 'USER_NAME_HERE'


ASP.Net | SQL Server

ASP.Net Membership Provider and Identity Login Password Hash with Salt/Security

by 9. January 2013 14:12

Here is a password for ASP.Net MembershipProvider
password: password1234
password salt: dArJQD4e4upwMyqCSl9iNA==
password: 5Xv212dMJiOQP2X+zhOZw66L+xU=

Here is a password for ASP.Net Identity
password: #%ND84yq
hash: AGRf+1XUhLtQsQnaT39V4sQegMmKvA7gsLBVtJ4YFLdvavNQFcqeHZ+ViuRoO9SkRg==
security: 86232225-81da-4d56-84ea-ded079d64384



SQL Read Sharepoint Document Content for SSRS Reports

by 6. December 2012 09:43

I had a case where I needed to review a few hundred SSRS reports installed on a Sharepoint 2010 envrionment.  Below is a SQL script I created to read the content from the underlying SQL database and search the report structure for certain keywords (in my case I was looking for specific database/table names in the report SQL).

create table #tmp(name varchar(150), content varchar(max))
/* Get cursor of all SSRS report (*.rdl) files to cycle through */
declare cur cursor for 
select Id, LeafName, InternalVersion 
from AllDocs where LeafName like '%.rdl'
declare @id varchar(50), @name varchar(200), @version int
open cur
while 1=1 begin
  fetch next from cur into @id, @name, @version
  if @@FETCH_STATUS <> 0 break
  /* Check is current version of the report contains specific keywords */
  if exists
    select 1 
	where Id = @id 
	and InternalVersion = @version 
	  cast(Content as varchar(max)) like '%KEYWORD #1 HERE%' 
	  cast(Content as varchar(max)) like '%KEYWORD #2 HERE%')
    insert into #tmp 
    select @name, cast(Content as varchar(max)) 
    from WSS_CONTENT_SITENAMEHERE.dbo.AllDocStreams 
    where Id = @id and InternalVersion = @version
close cur
deallocate cur
select * from #tmp
drop table #tmp


Sharepoint | SQL Server

C# Get First and Last Day of Previous Month

by 3. December 2012 08:25

To get the first day of previous month:

var firstDayPrevMonth = new DateTime(DateTime.Today.Year
  , DateTime.Today.Month, 1).AddMonths(-1);

To get the last day of previous month:

var lastDayPrevMonth = new DateTime(DateTime.Today.Year
  , DateTime.Today.Month, 1).AddDays(-1);




Lenovo T500 Display Brightness Not Working After Installing Windows 7 64bit

by 11. November 2012 11:41

One option that may work is BIOS update:

The other is installing the ATI ThinkPad Switchable Graphics Driver for Windows 7 (32-bit, 64-bit):