File sharing with Vista Home without passwords

After having several PC implosions, we now have two new Vista boxes at home. Both have Vista Home Premium installed. I’m used to the relative stability of XP Pro, but I figured I would give Vista a shot. For the most part it has gone very well, but I made sure that each machine was going to be able to run Vista.

My machine is a custom built box from MWave, my wife’s is a Dell box. She has Intel, I have AMD, but they are both dual core machines with 2GB of RAM and decent video cards.

My wife and my kids have user accounts with out passwords. The machine has the usual security apps installed and is behind a router firewall. Their accounts are set as Standard User. I have a password protected admin account on each box. My wife has a Standard User account on each box.

We share a printer from my machine. I could print from my wife’s PC, but she couldn’t. She kept getting a login pass prompt and finally an error message about being able to validate credentials. It took a little while to figure out, but finally I remembered that out of the box, Vista wont let non-password protected accounts from remotely authenticating. That means that you need a password on your account to access network resources on another Vista box.

A fair amount of Googling kicked up a few suggestions to run gpedit.msc (Group Policy Editor). Most of the suggestions were of this type:

Run gpedit.msc
Go to Computer Configuration / Windows Settings / Security Settings / Local Policies / Security Options
Double click on Accounts: Limit local account use of blank passwords to console login only
Disable this option

One little problem. You only get gpedit.msc with XP Pro or Vista Business (or Ultimate). Thanks for playing the Home version of Windows, you don’t get that useful little utility.

Fortunately for this setting all gpedit.msc is doing is writing to the registry. All you have to do is to edit the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

and edit the value of LimitBlankPasswordUse from 1 to 0. After you do that, you can now share printers and folders across Vista (and XP) with accounts that do not have passwords.

Updated on 8/15/2008
If you install Service Pack 1 (SP1) after making this change, you’ll need to do it again as SP1 restores this setting back to the default.

Allowing Comments on Blogs

I came across a posting by Dave Winer (via Joel) about blog comments.  Dave doesn’t easily allow commenting because he thinks it takes away from message that the blogger is putting out.  The power of blogging is that anyone (outside of some 3rd world countries) can express their own message.  Allowing comments brings in other views that can dilute or contradict your own view.

Joel adds the astute observation that allowing comments and lead to childish flame wars and other useless craps.  His view is that if you want to express your own view of a blog entry, post in on your blog.  Like this very posting.  I liked the Penny Arcade reference illustrating his point that anonymous posters are not always desired.

99% of I read in the blogs is through Google Reader, so I miss most of the comments anyways.  Usually, the only time I see comments on a blog is when I add a comment to a blog.  My experiences with comments has been pretty positive, with some rare comment spam.  Of course this blog is on the z-list and any comment is a rare event.

I can see that point.  But there is another side to blog commenting.  It allows the blog reader to correct or enhance positions posted by the author.  I have also seen plenty of blog postings where the author invited comments.  He/She was trying to solve a problem and was soliciting feedbacks.  As long as you can reasonably block comment spam, I’m in favor of allowing comments.  No one is forcing you to read them.

Implementing a sortable TCollection in Delphi

Delphi’s TCollection class is very useful, but out of the box it lacks the ability to sort the items in the list.  Fortunately, this is easily addressable accessing some private properties of the TCollection class.  Internally, the items in a TCollection are stored in a private TList named FList. 

The trick is to get access to a private property.  The way to do this is by creating a shadow class.  A shadow class is a class that matches the private declaration of the class that you need to access.  The shadow needs to have the same field types in the same order, up to and including the field that you need access to.  This is the risky part, and cover that risk later.  The definition of the TCollection class starts out with:

TCollection = class(TPersistent)
private
FItemClass: TCollectionItemClass;
FItems: TList;
FUpdateCount: Integer;
FNextID: Integer;
FPropName: string;

To get at FItems, we need to shadow the top two members of the class.  Which provides this shadow class:

TShadowedCollection = class(TPersistent)
private
FItemClass: TCollectionItemClass;
FItems: TList;
end;

With access to the internal list, it becomes a simple task to provide the ability to the sort the list.  A public Sort method will call an internal method that runs a Quicksort across the list.  The Quicksort code will process the list obtained by casting itself as TShadowedCollection, allowing access to FItems and then call a Compare() function to compare items in the FItems list.  The collection will provide a “do nothing” Compare() function.  It will be up to the descendant class to override that function and implement the actual comparision code.  The full source code for the class would look something like this:

unit SortCollections;

interface

uses classes;

type
TSortableCollection
= class(TCollection)
protected
function Compare(Item1, Item2 : TCollectionItem) : integer; virtual;
procedure QuickSort(L, R: Integer);
public
procedure Sort;
end;

implementation

type
// Helper class to allow sorting of a TCollection
{$HINTS OFF}
TShadowedCollection
= class(TPersistent)
private
FItemClass: TCollectionItemClass;
FItems: TList;
end;
{$HINTS ON}


{ TSortableCollection }

function TSortableCollection.Compare(Item1, Item2: TCollectionItem): integer;
begin
(*

Descendant classes would override this method and cast Item1 and Item2 to the
decendant class's collection item type perform the field comparisions

if item1.MyField < item2.MyField
return -1
else if item1.MyField > item2.MyField
return 1
else return 0

*)
result :
= 0;
end;

procedure TSortableCollection.QuickSort(L, R: Integer);
var
I, J, p: Integer;
Save: TCollectionItem;
SortList: TList;
begin
//This cast allows us to get at the private elements in the base class
SortList := TShadowedCollection(Self).FItems;

repeat
I :
= L;
J :
= R;
P :
= (L + R) shr 1;
repeat
while Compare(Items[I], Items[P]) < 0 do
Inc(I);
while Compare(Items[J], Items[P]) > 0 do
Dec(J);
if I <= J then begin
Save :
= SortList.Items[I];
SortList.Items[I] :
= SortList.Items[J];
SortList.Items[J] :
= Save;
if P = I then
P :
= J
else if P = J then
P :
= I;
Inc(I);
Dec(J);
end;
until I > J;
if L < J then
QuickSort(L, J);
L :
= I;
until I >= R;
end;

procedure TSortableCollection.Sort;
begin
if Count > 1 then
QuickSort(
0, pred(Count));
end;

end.

Tech Tags:

REST vs SOAP

In the weekly newsletter from TheServerSide.NET, there was a link to an article titled “REST versus SOAP – the REST story” by William Brogden.  It’s a few months old, but talk about the recent rise in REST types of services over XML-RPC and SOAP.   Brogden briefly covers REST, but he doesn’t talk about the advantages of REST and why you would ever want to use it over SOAP.  It’s obvious that he prefers SOAP, but the reasoning was left out of the article.

Having done SOAP and REST for accessing web services, I can see the where it’s advantageous to use SOAP as opposed to REST (or vice versa).  SOAP is very chatty, but you can send complex data structures to the web service.  Development tools like Visual Studio or Delphi can can read the WSDL from the web service and that gives you the “intellisense” autocompletion functionality that can save a lot of coding time.

With REST, you access the web service with just the basic HTTP GET and PUT commands.  You compose a URL for your web method request and the service sends back a response.  The response is usually in XML, but that is dependant on the functionality of the web service.

The drawback with SOAP is that there is more overhead in the construction of the method request and with the parsing of the request on the web service end.  When you have a web service that is serving thousands of requests a minute or second, that overheard may not be needed.

For web services that have relatively simple data types, using REST can provide the functionality that is needed.  You also get the advantage of testing individual method requests from a browser as the method request is basic URL. 

Blast from the past: Forth

I came across a link an online version to Leo Brodie’s Forth tutorial, “Starting Forth” today.  I used to have a copy of that book eons ago.  I learned how to program on a Commodore VIC-20 and I bought (actually had to special order it) a Forth language cartridge.  This book has been out of print for decades, the online version is probably the only way to read it now.

Forth is an arcane language that allows you to program in interactive and iterative manner.   You would create words (what other languages would call functions or subroutines) from the language core keywords and created new words from existing words.

The operators worked in post-fix notation (aka reverse Polish notation) like the older HP calculators.  The language was stack oriented and post-fix works well when you are pulling items off the stack.

Since Forth programs were very small in size and typically do not access or require a traditional file system, Forth was used in embedded controllers and other hardware related projects.  NASA uses Forth to this day for spacecraft flight system controllers and other projects.

Needless to say Forth and the VIC-20 were not the best fit and I never did too much with it.  I wonder how many geek points do you get for programming in Forth on 5K (but only 3.5k were usable) machine that had a whopping 22 columns of text per line?