Monday, January 28, 2008

Remove Shut Down button on Windows Server 2003

We recently assisted a client that has slowly moved from having staff in an office setting to most of them being virtual. Since they are doing away with their large office and instead going to a small office without the availability of a small server room we needed to move them to a data center. Part of the move required that we allowed access to their accounting data and software which has always resided on a machine in their office. We installed all software successfully on a Windows Server 2003 Standard machine however we wanted to make sure they don't hit Shutdown when logging off through the Start Menu since all accounting work will now be performed through a Remote Desktop connection. It is a simple registry addition as indicated below.

Key Location: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Type: REG_DWORD
Name: NoClose
Value: 1

Thursday, January 24, 2008

IPKG Update Problems

When attempting to run the command to update ipkg on a new unslung box I kept seeing the following issue.

user@machine ~> ipkg update
ipkg_conf_init: Failed to create temporary directory `(null)': No such file or directory


Since I hadn't set up an unslung box in quite awhile I couldn't remember how I'd fixed this before after I switch over to using bash instead of the default sh. Then like a flash it hit me...temporary directory genius.

user@machine ~> mkdir ~/tmp

Now it works like a charm.

Tuesday, January 22, 2008

Synchronize/Update Time on Active Directory DC

Recently while performing some updates on a couple of DC on a Windows only corporate network I noticed the time seemed off by more than 10 minutes. After a little investigation it appears that the time wasn't being updated. Using Google as my dear online search friend I came across this post. The script has been saved to a .bat file that is run on as a schedule task now so the problem is a thing of the past (pun intended).

On the main DC:
NET TIME /SETSNTP:time.windows.com
NET STOP W32TIME
NET START W32TIME
W32TM /config /reliable:YES
W32TM /resync /rediscover


On all other DCs:
W32TM /resync /rediscover

Thanks Chrissy for the good work on that one and make sure to visit Chrissy's blog.

Tuesday, January 1, 2008

Microsoft Word 2000 Unspecified Code Execution Vulnerability

What can you do about it, nothing until Microsoft issues a patch but you should be aware of it. Here is the overview from SecurityFocus:


Microsoft Word 2000 is prone to an unspecified remote code-execution vulnerability.

Microsoft Word 2000 is confirmed vulnerable to an unspecified remote code-execution issue. Exploit attempts against Word 2003/XP will consume all CPU resources and will cause a denial of service for legitimate users.

Note that this issue is distinct from issues described in BID 21589 (Microsoft Word Code Execution Vulnerability), BID 21451 (Microsoft Word Unspecified Remote Code Execution Vulnerability), and BID 21518 (Microsoft Word Unspecified Code Execution Vulnerability).


The only preventative measure being offered currently is this one by Symantec.


To protect yourself against these threats, do not trust unsolicited files or documents about “interesting” topics. Do not open attachments unless they are expected and come from a known and trusted source.

SharePoint 2003 Menus (MSOWebPartPage_OpenMenu)

As we were attempting to add custom menus to SharePoint 2003 we discovered that is was actually pretty easy using a built in JavaScript function provided (and utilitized) by SharePoint. The function name is MSOWebPartPage_OpenMenu and the problem was that the posts we found discussing how to do it with SharePoint seemed to indicate that the function allowed some optional parameters but we couldn't seem to locate an online reference describing the function in detail. Since we're not SharePoint 'gurus' we did a search of our server which indicated that it was getting pulled from the IE55UP.js file.


function MSOWebPartPage_OpenMenu(MenuToOpen,SourceElement,WebPart,InConnectionsMode)
{
if(WebPart)
{
MenuWebPart = WebPart
MenuWebPartID = WebPart.WebPartID;
var minOption = MenuToOpen.all.item('MSOMenu_Minimize');
var restoreOption = MenuToOpen.all.item('MSOMenu_Restore');
var closeOption = MenuToOpen.all.item('MSOMenu_Close');
var deleteOption = MenuToOpen.all.item('MSOMenu_Delete');
var exportOption = MenuToOpen.all.item('MSOMenu_Export');
var resetPersOption = MenuToOpen.all.item('MSOMenu_RestorePartDefaults');
var helpOption = MenuToOpen.all.item('MSOMenu_Help');
var connectionOption = MenuToOpen.all.item('MSOMenu_Connections');
if(minOption)
{
minOption.style.display = (WebPart.allowMinimize == 'false' || WebPart.style.display == 'none') ? 'none' : '';
}
if(restoreOption)
{
restoreOption.style.display = (WebPart.allowMinimize == 'false' || WebPart.style.display != 'none') ? 'none' : '';
}
if(closeOption)
{
closeOption.style.display = (WebPart.allowRemove == 'false') ? 'none' : '';
}
if(deleteOption)
{
deleteOption.style.display = (MSOLayout_inDesignMode && WebPart.allowDelete != 'false') ? '' : 'none';
}
if(exportOption)
{
exportOption.style.display = (WebPart.allowExport == 'false') ? 'none' : '';
}
if(helpOption)
{
helpOption.style.display = (WebPart.helpLink == null) ? 'none' : "";
}
if(resetPersOption)
{
resetPersOption.style.display = (MSOLayout_inDesignMode && WebPart.HasPers == 'true' && WebPart.OnlyForMePart != 'true') ? '' : 'none';
}
if(connectionOption)
{
connectionOption.style.display = (MSOLayout_inDesignMode ? '' : 'none');
}
if(InConnectionsMode != 'False')
{
var connMenu = document.all.item('MSOMenu_Connections'+WebPart.id);
if(connectionOption != null && connMenu != null)
{
connectionOption.outerHTML = connMenu.innerHTML;
}
}
}
try
{
if (!MenuToOpen.isOpen()) MenuToOpen.show(SourceElement, true);
}
catch(e)
{
}
}


In case you're looking for how to build a menu in SharePoint see these links:
SharePoint Menus - roll your own
WSS Navigation

ASP.NET - Store ViewState in Database using VB.NET

We had finally crossed the barrier of ViewState performance and were watching our application performance drop signficantly. I did the usual websearches and arrived at two solutions: 1) start changing major bits of code to not use ViewState and/or 2) store ViewState in the database.

This page made it seem easy however the one issue was that we're using VB.NET and not C#. From some additional searching it appeared that no one had made the change to store it in the database using VB.NET so I decided to go after it. It really didn't take long to recode in VB.NET however I know there are a few issues with the code (i.e. it is ugly and uncommented) however I wanted to get something out there in the event it helps someone out sooner than waiting and not getting it posted for another month or two.

SqlViewState Class
Database Code

To use just change your code to inherit from the class instead of the System.Web.UI.Page. The performance difference in our case was significant. We know we need to move to AJAX however when we started the AJAX stuff was not mature enough for our use so this solution is easy to implement and we saw a 5% to 30% increase in performance. If you look at the source of the page you'll see the following:


<input type="hidden" name="__VIEWSTATEGUID" value="130adb08-0644-470a-9c3b-0cc630defd32" />
<input type="hidden" name="__VIEWSTATE" value="" />