Friday, April 27, 2012

Microsoft DNS Web Admin

Most if not all DNS servers have a web interface, why not Microsoft's DNS?


I decided to write one, just because I got tired from logging in to a server every time I wanted to change something, yes, I know about remote management, it wasn't an option for that particular case. time passed by and by the time I was almost done, the project was irrelevant, I did have some fun writing it though!


So here it is before you, mostly working, some parts don't, mostly tested. 


https://github.com/drorgl/MSDNSWebAdmin


If you'd like to finish it, enjoy, its on github just for that.






Project contains two interesting libraries:


Heijden.DNS - for querying everything a DNS can tell you, including a trace.


DNSManagement - C# wrapper for WMI MicrosoftDNS namespace.

Tuesday, April 10, 2012

Unix to DateTime to Unix

If you need to convert from .NET DateTime to Unix datetime and back, here's how:


/// <summary>
/// Converts a unix datetime to C# DateTime
/// </summary>
/// <param name="unixTimeStamp"></param>
/// <returns></returns>
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
    // Unix timestamp is seconds past epoch
    System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
    dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToUniversalTime();
    return dtDateTime;
}


/// <summary>
/// Converts C# DateTime to unix datetime
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static double DateTimeToUnixTimestamp(DateTime dateTime)
{
    return (dateTime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime()).TotalSeconds;
}


From here.