Friday 17 January 2014

Windows 8 - RDP using Blank Password

On Windows machines, by default you are not permitted to establish a Remote Desktop connection with a user account having a NULL (Blank) Password.
Trying to do so, you might come across error messages like:
"Unable to log you on because of an account restriction."

As a matter of fact this is the case not only with Remote Desktop connections, but also with any logon attempts to a Windows machine over network with a blank password.

The first work around for this behavior is to set a password for the user account and use it to logoon remotely. But I guess this is not what you are looking for right now. So lets look at the next option.

The second option allows you to logon with a blank pasword.
For this you will have to disable blank password restrictions using a policy on the machine. Follow the below simple steps on the machine to which you want to establish remote desktop connection.

  1. Click Start, point to Run, type gpedit.msc, and then click OK to start the Group Policy Editor.
  2. Open Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\Accounts: Limit local account use of blank passwords to console logon only.
  3. Double-click Limit local account use of blank passwords to consol logon only.
  4. Click Disabled, and then click OK.
  5. Quit Group Policy Editor.
You might have to restart / log off and login to the machine to which you want to establish the remote connection before you try the remote connection with blank password.

Tuesday 7 January 2014

Winforms C# - AutoComplete for Textbox and ComboBox

Recently I came across the autocompletion feature in WinForms TextBox control.
My requirement was to have an autocomplete textbox with the file paths and file names like windows explorer address bar.
Instead of writing the whole functionality myself I was really excited to find the built in autocomplete feature with windows forms controls.
You need to set 2 properties (AutoCompleteSource and AutoCompleteMode) of Textbox and ComboBox controls to use the built in AutoComplete features. The properties can be set either at design time or at runtime via code.

Both the properties are enumerations. The values are explained below:

AutoCompleteSource Enumeration :
  • AllSystemResources – Specifies the equivalent of FileSystem and AllUrl as the source. This is the default value when AutoCompleteMode has been set to a value other than the default.
  • AllUrl – Specifies the equivalent of HistoryList and RecentlyUsedList as the source.
  • CustomSource – Specifies strings from a built-in AutoCompleteStringCollection as the source.
  • FileSystem – Specifies the file system as the source.
  • FileSystemDirectories – Specifies that only directory names and not file names will be automatically completed.
  • HistoryList – Includes the Uniform Resource Locators (URLs) in the history list.
  • ListItems – Specifies that the items of the ComboBox represent the source.
  • None – Specifies that no AutoCompleteSource is currently in use. This is the default value of AutoCompleteSource.
  • RecentlyUsedList – Includes the Uniform Resource Locators (URLs) in the list of those URLs most recently used.
AutoCompleteMode enumeration:
  • Append – Appends the remainder of the most likely candidate string to the existing characters, highlighting the appended characters.
  • None – Disables the automatic completion feature for the ComboBox and TextBox controls.
  • Suggest – Displays the auxiliary drop-down list associated with the edit control. This drop-down is populated with one or more suggested completion strings.
  • SuggestAppend – Applies both Suggest and Append options

Example: AutoComplete with file path on typing in the Textbox. (Like Windows Explorer Address Bar and Run Dialog)
Textbox1.AutoCompleteSource = AutoCompleteSource.FileSystem;
Textbox1.AutoCompleteMode = AutoCompleteMode.Suggest;