.Net WiFi Programming

free wifiSome time ago I was asked to write some code to

  1. detect if a user had saved a connection to an Open/Public Wifi point, and
  2. delete it if it exists.

The code had to work on Windows 7, so using the Wi-Fi Direct feature wasn’t available to me.

I could do this using the Native WiFi API, except that doing that from .Net isn’t easy.

So I used the managedwifi wrapper which Monfort Engineering developed and made open source.

Everything worked well except …

The code would occasionally fail.  Much reading of documentation, and lots of head scratching happened.  This was the answer:

“All wireless LAN functions require an interface GUID for the wireless interface when performing profile operations. When a wireless interface is removed, its state is cleared from Wireless LAN Service (WLANSVC) and no profile operations are possible.”
WlanSetProfile function

What that means in practice:

  1. if the Wireless LAN Service is not running, then there is no WiFi running
  2. if the user has disabled the WiFi Adapter, then there is no WiFi to query.

So if 1 or 2 occurred, the code I wrote would fail.

The code to fix that was as simple as this:

Private Sub DeleteOpenWifi()
If wifi.Interfaces.Length = 0 Then
     Exit Sub
End If

How to Avoid Public WiFi Security Risks
About the Native Wifi API
Managed WiFi API (Codeplex)
Is there anyway of detecting what wireless security is being used i.e WPA2, WEP, open etc?

Getting the user name for a given security identifier (SID)

Two lines of Powershell code:

PS C:\> $osid=New-Object system.security.principal.securityidentifier("S-1-5-21-593069383-354653268-975305329-98179")

PS C:\> Write-Host $osid.translate([system.security.principal.ntaccount])

Output is in the form of <DOMAIN>\<USERID>

ie. NODDYLAND\admin-bike01

Microsoft: Well-known security identifiers in Windows operating systems

Things you can do with Bi-Carb Soda

Bi-Carb SodaAround The House

  • Remove dry ink strains by covering strain with a paste of Bicarb and water.  Allow paste to dry and then rub off.
  • Brighten dull silver by dipping it into a boiling solution of water and two teaspoons of Bicarb.
  • Remove unpleasant or musty odours from rooms by placing a container of charcoal sprinkled liberally with Bicarb in the room.
  • One tablespoon of Bicarb and half a cup of vinegar helps clear blocked drains.  Allow the mixture to effervesce and then pour down the sink along with a kettle of boiling water.  Put plug in quickly and leave for two hours.
  • One cup of Bicarb tipped down the toilet each week will improve a septic system by creating a favourable pH level for better sewage digestion.  Also helps reduce odours.
  • To remove coffee or other liquids spilt on carpet, just pour Bicarb onto the affected area and vacuum/brush when dry.  Also works for fabric upholstery.

In The Laundry
Continue reading

Samba–like the walking dead.

The Microsoft SMB1 file protocol is old, has vulnerabilities and deserves to die.

So we tried to remove it from our Windows 7 desktop fleet.  Like any good removal, we piloted it, and we found it broke connections to Samba file servers.

Will no one rid me of this turbulent piece of software?

So I left the Windows 7 desktop fleet alone.  We were getting ready to deploy Windows 10, and I thought “Here’s an opportunity for a clean slate”.

We started deploying Windows 10, and the calls started to roll in.

“Our network drives no longer work.”

This time, we were better prepared.  Instead of 100% of the desktop users getting the SMB1 protocol turned back on, we have only enabled it for the 5% of desktop users who actually need it.

I am a “Summer”

SummerKnow this, I dislike light colours as they make me look fat(ter).

I know some talented people, and one of them is a colour consultant.  Friend of my friend.

My friend, bless her, made me realise that there are things I have poor judgement in.  Choice is clothing colours is one of those.  She has good taste in clothing.  The colour consultant agrees.

So now, I’m dressing lighter.

Crease free business shirt folding

as seen in Ride On Magazine:

Ask ten cyclists the best way to fold a business shirt, and you will get ten different answers. Ride On went undercover and discovered the technique for shirt folding used by the Royal Australian Air Force.

Illustration by Genna Campton

1. Lay the shirt face-down on the folding surface. Smooth out any wrinkles so the shirt is completely flat.

2. From the right side of the shirt, fold about one-third of the body in toward the centre of the shirt. The fold line starts at the centre of the shoulder and ends at the tail. You should see the back of your shirt with about one-third of the front folded to the back.

3. Neatly fold the sleeve forward, creating an angled fold at the shoulder. The sleeve should line up with the edge of the first body fold.

4. Fold the left side in the same manner.

5. Fold the shirt tail up several inches and then fold again, moving the bottom edge to just behind the collar of the shirt. Turn the entire shirt over. Ta-dah!

6. Many riders use the fold and roll technique; once folded, the shirt is rolled up to form a tube.

Shirt folding boards that help ensure a consistent fold can be purchased, or made out of stiff cardboard.

Some advise limiting the amount of friction between fabric layers to lessen the amount of creases. This can be done by layering the shirt between two big pieces of plastic, such as a dry-cleaning or garbage bag, and folding the shirt as normal, but with the plastic between the folds. This will prevent creases ‘sticking’ as the fabric is not rubbing against itself.

Spacious panniers or a big bag minimise crushing or you might also stash a few days’ worth of clothing at work on a non-riding day. Many people use a combination of options, depending on weather, storage and change facilities at their workplace.

Active Directory Account Lockouts and SAMBA …

Going though the backlog of things to log about, I found this from 2014.

Hello Bill,

The issue you are seeing is because your SAMBA File Servers are not part of our Active Directory Domain.

So the SAMBA shares folks are connecting to are not within the MSWINDOWS domain, there is no trust relationship between MSWINDOWS and your SAMBA workgroup/domains.  Microsoft Windows by default will always attempt to connect or reconnect with the logged-in users domain credentials (ie. MSWINDOWS) first, IF you do not supply your Samba domain\user credentials.

Lockout occurs from your end when a certain number of incorrect authentication attempts are detected.

So what you should do is map your SAMBA network drives as a different user from Windows explorer, explicitly specifying the Workgroup (“SAMBAPC\userid” in the case of shares to SAMBAPC) or domain (“SAMBADOMAIN\userid” for everything else) for the relevant user.

If this is done it generally avoids the issue.

Still true 4 years later.