Remko Weijnen's Blog (Remko's Blog)

About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like

Archive for October, 2012

A customer had partially implemented a (written) policy in the past where the the Local Administrator account was renamed according to a special convention.

This policy stated that the Administrator account needed to be renamed to admin with the computername as a prefix.

However they didn’t know exactly on which machines this policy had been applied to in the past. I was asked to write a script that would check a list of machine names, query the Administrator account name and write this in a new list.

The Administrator account has a Well Known SID of S-1-5-21-xxxxxxx-500 where xxxxxxx is the SID of the computer.

(more…)

  • 0 Comments
  • Filed under: PowerShell
  • Yesterday I wrote about converting an IP Address to an Integer in C#. But both methods I presented return the IP Address in network byte order.

    However in some cases, especially when calling WinApi functions, you will need to convert the Integer to host byte order which is little-endian on Intel processors.

    In an unmanaged language we could do very fast byte swap with inline assembly, eg:

    From WinApi we could use the ntohl function and in managed languages we can use the NetworkToHostOrder method from the System.Net.IPAddress class.

    For an IPv4 address we need to make sure we are using the proper overload by casting the result of System.BitConverter to an int:

     

  • 0 Comments
  • Filed under: C#
  • For a call to a WinApi function I needed to convert an IP Address to an Integer in C#.

    This can be done using the System.Net.IPAddress class:

    Although this works, the compiler issues a warning: 

    warning CS0618: ‘System.Net.IPAddress.Address’ is obsolete: ‘This property has been deprecated. It is address family dependent. Please use IPAddress.Equals method to perform comparisons. http://go.microsoft.com/fwlink/?linkid=14202′

    This warning is issued because the Address property is not IPv6 compatible. The warning can be suppressed like this:

    But it would be better to use the non deprecated GetAddressBytes() Method:

  • 1 Comment
  • Filed under: C#
  • Blogroll


    Categories


    Archives