New version of AD/Federated password tool

I have uploaded a new version of the password tool. There are 2 features added:

  1. Support for a SSL connection to your domain controller. Since some time it is mandatory to use SSL for password related operations
  2. Support for a SSL connection to the SMTP server. As requested in the comments. I’am using the .net SmptClient with its limitations. (I believe one of them is self signed certificates on 465)

You can find the options to enable/disable SSL on the setup page. Let me know if you would like to know how to enable SSL on your Domain Controller.

Posted in Uncategorized | Leave a comment

Youless and OpenHAB + Grafana

A while ago i started using OpenHAB in my home. For this i bought a raspberry pi, Aeotec z-wave stick, 3 power meters and a fibaro switch and roller shutter.I had a little trouble getting started and understanding how it works, but with the help of a friend i managed to make a start.

One nice thing in OpenHAB are panels you can create with HABPanel. My ultimate goal is to have tablet lying around in the living room to control and see the status of things/items in my house. One thing i wanted to see was the power consumption of my house and split PV output. Currently i use a youless to measure this. The youless is connected to enelogic which has some nice dashboards but not so easy to add to OpenHAB. Fortunately youless has also a interface to collect data in json format. This was easy to implement in OpenHAB. So i made this HABPanel:

I thought it would be nice to share how i did it. Although it is fairly simple to do it, finding out how took me quite some time. First you need to install the following add-ons: HTTP binding and JSONPath Transformation. Once you have those installed you need to create an item. You can do this by creating an .item file in /etc/openhab2/items. For example youless.item. Below you can find mine (i have a youless LS110 and LS120, LS110 is for measuring a car charing station):

//----- Energy
Number Youless_NetUsage "Netto verbruik" { http="<[http:///a?f=j:5000:JSONPATH($.pwr)]" }
Number Youless_PV "ZP Opbrengst" { http="<[http:///a?f=j:5000:JSONPATH($.ps0)]" }
Number Youless_Gross "Bruto verbruik"

Number Youless_CarCharcher "Laadpaal verbruik" { http="<[http:///a?f=j:5000:JSONPATH($.pwr)]" }

And actually thats it. When you add a widget you can find the Youless items. As you can see there is a Youless_Gross, this is a virtual item. The Youless only supplies net use and PV output. Not what you are actually using. So i am using a rule to calculate this item. The rule i am using:

rule "Update youless gross usage"
when
   Item Youless_NetUsage changed or
   Item Youless_PV changed
then
   var gross_value = (Youless_NetUsage.state as Number) + (Youless_PV.state as Number)
   Youless_Gross.postUpdate(gross_value)
   logInfo("info","Updated Youless gross")
end

Nice addition is that i can graph this data in Grafana. I also have the InfluxDB persistence plugin installed.

Posted in Uncategorized | Tagged , , , | Leave a comment

Webbased Active Directory / Federated user password and recovery tool (IISADMPWD replacement)

A while ago i wrote a simple tool which allows users to reset their expired password as a replacement for IISADMPWD. The tool was created because at the time Office 365 did not have the ability to let federated users change their password. I have noticed that i was not the only one who had to deal with this problem, the tool was downloaded a number of times and i got some positive feedback. The tool was still very limited, if a user forgot his password, he still had to contact someone from IT to reset his password. Because remembering a password is one of the hardest things to do, resetting passwords for users took up to much of our time. This is why i build the Webbased Active Directory / Federated user password and recovery tool which allows users to recover their account through a reset link sent to an alternative e-mail address. On this page you can find how to install, customize and download the tool. You can see it as a self-service portal for users.

For the first version of the IISADMPWD replacement tool i have made the source code available for download.

Posted in .net, IIS, Office 365, Windows | Tagged , , , , , , , , , , | 1 Comment

Mail Performance Monitor and AWStats Totals

Recently i have added 2 solutions to my software and scripts section:

  • The first tool is Mail Performance Monitor which  allows you to measure how long it takes to get a mail delivered from one mail account to another. More info here.
  • The second tool is a tool to display monthly awstats totals of multiple sites on one page. More info here.

 

Posted in .net, General, IIS, Windows | Tagged , , , , , | Leave a comment

Server 2012: The remote session was disconnected because there are no remote desktop license severs available to provide a license

If you ever get the error message in the title when connecting to a RDS session host while your licenses are OK, try the following:

  • Open Regedit on the host(s)
  • Navigate to HKLM\System\CurrentControlSet\Control\Terminal Server\RCM
  • Take ownership of the GracePeriod key
  • Delete it
  • Reboot server

Found on:
http://www.stopdoingitwrong.co.uk/server-2012-rds-there-are-no-remote-desktop-license-servers/

Posted in Windows | Tagged , , , , | Leave a comment

Ugoos MK809IV

A while ago i bought an Android TV stick to use as a mediaplayer from iBood. I bought it trough their daily offer. Nice addition was the USB Fast Ethernet adapter (WiFi sucks). Specs of the stick:

  • Quad Core RK3188 Cortex-A9 1.4GHZ
  • 2GB DDR3 Ram
  • 8GB NAND ROM
  • MALI 400 MP GPU
  • WIFI & Bluetooth
  • MicroSD slot

Pictures:
android-stick (1) android-stick (2) android-stick (3) android-stick (4) android-stick (5)

First run
When i first tried the stick i was disappointed. The stick came with an android 4.4 kitkat rom but it was really slow. Starting an app took forever and the interface was really sluggish. CPU-Z told me the CPU was a quad core 1.0GHZ cpu??. So i went to
ugoos.net and downloaded their Android 4.2 ROM(4.4 was nowhere to be seen, why did it have 4.4 out of the box?). This was a HUGE improvement. Interface was fluent and apps started fast enough. But still i was not satisfied. Video playback in apps (xbmc 13 beta1 & beta2 and mx player pro) was shocky. Also the NAND was divided in 2GB app space and 5.x GB internal SD (why?).

Fixing problems
So i went out to look for a custom ROM, only to find out that none of the ROMs worked. I bricked my stick several times and had to use the short-pin-7&8-trick to re-flash the original firmware. I think this Android stick is some exotic variant of the original MK809IV. Every tool, rom or download that i tried wouldn’t work. In my search i learned that the shocky playback was caused by a v-sync bug in the kernel. But even flashing a patched kernel did not work. After a while i found a download RK3xxx firmware tools which is a very nice tool to extract, modify and build rokchip firmware’s. This also allows you to add or remove APK’s from the rom AND increase the app space on the NAND by using a paramater file. This could fix most of my problems but not the v-sync bug.

V-Sync bug and OC!
So using the firmware tools described earlier, i was be able to extact the firmware obtained from ugoos. The tool extracts various parts from the firmware:

  • boot.img
  • kernel.img
  • misc.img
  • recovery.img
  • system.img

The tool will also let you extract and build system.img to modify android (Remove bloatware, add binaries, etc). I tried to replace the kernel.img by a patched one found online only to find out it didn’t work. After a long search i found some perl scripts. The creator of the script claimed that the script could patch any RK3188 kernel and also build OC kernels. So i let them patch my kernel and it worked! After that i build a new ROM with the new kernel (and other parameter file) and this fixed the v-sync bug. After applying the v-sync patch it is possible to create OC kernels,  CPU can be OC-ed up to 1.9GHZ, GPU up to 800MHZ and memory up to 800MHZ. The script creates a kernel for each possible combination.

Increase App space
To increase App space you can extract the firmware using the firmware tools and replace a parameter file to change the layout of the NAND flash. I downloaded these parameter files somewhere but i have no idea where. Therefore i will add them to this post but kudo’s to the guy who created them. After extracting the firmware you can find the parameter file in temp/Android. Simply replace the parameter file by any of the attached parameter files and rebuild+flash the image. Parameter2GB would create 2GB of App space, Parameter6GB would leave you with 6GB of App space (and about 700MB of internal SD space). You can find the parameter files here.

Unbrick your Stick
As i mentioned earlier, i bricked my stick a few times. If you did a bad flash and your stick won’t boot and windows shows unrecognized device when you connect it, you can recover by shorting pin 7 & 8 of the flash chip while powering it on. This enable’s some hardware flash mode which allows you to flash the original rom to the device. I used the tip of a small knife to short the pins, see the picture below:
android-stick-short78

Root & Bluetooth
2 things about the stick are still a ‘problem’. The first problem is that i couldn’t get root on the device, i modified the ROM by superuser.apk and the su binary, but superuser keeps telling me that the su binary is missing. The other thing is poor bluetooth performance. I connected a BT keyboard and especially when WiFi was doing a lot of traffic it was impossible to use the keyboard or mouse. I ended up buying a mini RF Keyboard/Touchpad which uses it’s own dongle.

Update 1
I’ve managed to get root on the device. I tried this for a while on a Windows 8.1 machine but i couldn’t get the ADB driver to work. On Windows 7 i got the drivers to work using the AdbDriverInstaller.exe file. After that i used TPSparkyRoot.bat (google it) to root the device.

I have uploaded and added the patched ROM for download as requested. The ROM has stock clocks, v-sync patch applied and some bloatware removed. App space is 6GB and 700MB internal SD card storage. I’ve also uploaded a zip file (see below) with all the possible patched OC and stock kernels (generated by the Perl scripts) so you can flash only the kernel using the RK3xxx firmware tools . If you are interested where the Android 4.4 (Beta) ROM came from: i found it here. I’ve read in a thread on iBood that the developers of the ROM expect to release an Android 4.4 final ROM somewhere next week.

Resources
If you want to link to the download, please link to this page and not the direct file. Thanks!

Other Resources

Posted in Android | Tagged , , , , , , , , , | 18 Comments

Compress/Zip IIS Logs using Powershell

In my short search for a script which can compress IIS log files i couldn’t find any solution (written in powershell). So i made my one myself. The script compresses all .log files located in the sub directories of $LogDir and files newer than 5 days are skipped. The script uses the zip functionality present in windows so no external programs are needed. The script was tested on Windows 2008 Server R2.

$LogDir = "D:\Logs"
 
function Zip-Logs
{
    foreach($Dir in Get-ChildItem $LogDir | ?{ $_.PSIsContainer } )
    {
        foreach ($file in Get-ChildItem -Filter *.log $Dir.FullName)
        {
            $TimeSpan = New-TimeSpan ($file.LastWriteTime) (Get-Date)
            $filename = $file.FullName + ".zip"
 
            if ($TimeSpan.TotalDays -gt 5)
            {
                #Create Zip
                New-Zip -zipfilename $filename
                #Add file
                $file | Add-Zip -zipfilename $filename
                #Delete the uncompressed file
                $file.Delete()
            }
        }
    }
}
 
function Add-Zip
{
	param([string]$zipfilename)
 
	if(-not (test-path($zipfilename)))
	{
		set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
		(dir $zipfilename).IsReadOnly = $false	
	}
 
	$shellApplication = new-object -com shell.application
	$zipPackage = $shellApplication.NameSpace($zipfilename)
 
	foreach($file in $input) 
	{ 
        $zipPackage.CopyHere($file.FullName)
 
        #This waits for the zip operation to finish
        while($zipPackage.Items().Item($file.Name) -Eq $null)
        {
            start-sleep -m 10
        }
	}
}
 
function New-Zip
{
	param([string]$zipfilename)
	set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
	(dir $zipfilename).IsReadOnly = $false
}
 
Zip-Logs
Posted in IIS, Powershell, Windows | Tagged , , , , , | Leave a comment

Autodiscover to external Exchange Server

Recently i had to migrate office mail from an on-premise Exchange (2010) server to Office 365. After the “switch over” (and changing DNS settings for mail and auto-discover to the Microsoft servers) i noticed that Outlook (2007) on the on-site PC’s which are member of the local domain, still auto-discovered to the on-premise exchange server. After some digging around i found out that outlook retrieves this information from Active Directory and you can change this via Active Directory Sites and Services.

  • Once opened, navigate to Services -> Microsoft Exchange -> -> Administrative Groups -> -> Servers -> -> Protocols -> Autodiscover.
  • Right click on your server and choose properties.
  • Go to the Tab Attribute Editor
  • Look for the setting serviceBindingInformation and change it to your needs.
  • OK to apply

After this change, Outlook auto-discovered to the correct server.
SCP AD autodiscover aanpassen

Note: If you don’t see Services, click View -> Show Services Node

Posted in Exchange 2010, Office 365, Windows | Leave a comment

Adaptec Raidstatus script for ESXi

As promised in my previous post i made a (Powershell) script which can be automated to run as a scheduled task. The script is build to run once a day. It sends an email if there is an error in the controller or one of the (logical) drive’s. On friday it always sends an email so you will know the script is still working 😉

It’s my first Powershell script so feel free to leave a comment with possible improvements 😉

<#
Script Name         : Adaptac Array Health checker
Version             : 20130419
Author              : Luke Voorn
Description         : Checks the health status of an array trough arcconf provider on ESXi
TODO                :
#>

# -------------------------------------------------------------- #
# Variables
# -------------------------------------------------------------- #

$ESXI_SERVER = "192.168.1.10"
$ESXI_PORT = "5989"
$ESXI_USER = "raidstatus"
$ESXI_PASSWORD = "raidstatuspassword"
$ADAPTEC_CARD = "1"
$ARCCONF_PATH = "C:\Program Files (x86)\Adaptec\RemoteArcconf\arcconf.exe"
[string[]]$MAILTO = "email1@domain.nl", "email2@domain.nl"
$MAILFROM = "email3@domain.nl"
$SMTPSERVER = "192.168.1.20"

# -------------------------------------------------------------- #
# End Variables
# -------------------------------------------------------------- #

$global:SomethingInError="False"

function GetStatusData {
    $ARCCONF_ARG = " SETVMCREDENTIAL $ESXI_SERVER $ESXI_PORT $ESXI_USER $ESXI_PASSWORD"
    Start-Process $ARCCONF_PATH -ArgumentList " $ARCCONF_ARG" -Wait
    $result = &$ARCCONF_PATH getconfig $ADAPTEC_CARD
    return $result
}

function ParseTheData {
    param([string[]]$FunctionInput)
    
    $Count = 0
    $Output = @() #create empty error

    ForEach($s in $FunctionInput) {
        If ($s.Contains("Controller Status") -and $s.Contains("Optimal")){
            $Output + $s
        }
        ElseIf ($s.Contains("Controller Status") -and !$s.Contains("Optimal")){
            $Output + $s
            $global:SomethingInError = "True"
        }


        if ($s.Contains("Status of logical device") -and $s.Contains("Optimal")){
            $Output += $s
        }
        elseif ($s.Contains("Status of logical device") -and !$s.Contains("Optimal")){
            $Output += $s
            $global:SomethingInError = "True"
        }

         if ($s.Contains("Device is a Hard drive") -and $FunctionInput.GetValue($Count +1).Contains("Online")){
            $Output += ($FunctionInput.GetValue($Count -1)) + ($FunctionInput.GetValue($Count +1))
        }
        elseif ($s.Contains("Device is a Hard drive") -and !$FunctionInput.GetValue($Count +1).Contains("Online")){
            $Output += ($FunctionInput.GetValue($Count -1)) + ($FunctionInput.GetValue($Count +1))
            $global:SomethingInError = "True"
        }

        $Count++
    }
    return $Output
}

function MailResults {
        param([string[]]$ResultArray)

        $MAILSUBJECT = ""
        $MAILBODY = ""

        ForEach ($s in $ResultArray){

            $MAILBODY = $MAILBODY + $s
            $MAILBODY = $MAILBODY + [Environment]::NewLine
        }


        if ($global:SomethingInError -eq "True"){
            $MAILSUBJECT = "Adapter in ERROR"

        }
        elseif ((Get-Date).DayOfWeek.value__ -eq 5 -and $global:SomethingInError -eq "False"){
            $MAILSUBJECT = "Adapter OK: weekly status"
        }
        

        ForEach($e in $MAILTO){
            Send-MailMessage -to "$e" -Subject "$MAILSUBJECT" -from "$MAILFROM" -body "$MAILBODY" -SmtpServer "$SMTPSERVER" 
        }

}
$Raw = GetStatusData
$result = ParseTheData -FunctionInput $Raw
MailResults -ResultArray $result

Posted in Powershell, Vmware, Windows | Tagged , , , | 4 Comments

Monitor Adaptec 3405 health on VMware ESXi 5.x

For my work i had to install a supermicro server with ESXi 5.1. This server had a adaptec 3405 raid card which works fine with ESXi 5.x but you can’t see the health status of the array(s) in the VSphere Client. After a lot of messing around with esxi drivers i did not get this to work. There is however a way to monitor the array status and this is done from a guest OS (in my case windows 8), or if you have one, another server.

To get this working you need to follow the following steps:

  • Download cim_vmware_v7_30_18837.zip from adaptec. If you can’t find it, let me know in the comments and i will mail it to you.
  • Extract vmware-esx-provider-arcconf.vib from the zip file. It is located in cim\esxi5_0\cim
  • Install the VIB using esxcli (google it if you don’t know how)
  • Reboot? Not sure if this is needed.
  • Now install remote arcconf also found in the ZIP file. Arcconf is available for linux and windows. I used the windows version.
  • Open an elevated command prompt and run the following commands:

arcconf SETVMCREDENTIAL 192.168.1.1 5989 esxiUser esxiPassword
arcconf getconfig 1

The first command sets the connection info to your ESXi host, 192.168.1.1 is the IP, 5989 is the default TCP port, esxiUser the user and esxiPassword the password. The account needs administrator permissions to make this work. I will try to find out if an read only account is possible.

The second command gets the config/status of the first adapter on the ESXI machine. You can easily write a script to fetch the status and email it using powershell for example. I am going to write such a script and will post it here when finished.

UPDATE: You can find the script here: https://www.tuser.nl/2013/04/19/adaptec-raidstatus-script-for-esxi/
UPDATE 2: Please read the post from Christoph below (thanks!). An additional piece of software is needed to make this work.

The output of the command should be something like this:

Controllers found: 1
----------------------------------------------------------------------
Controller information
----------------------------------------------------------------------
   Controller Status                        : Optimal
   Channel description                      : SAS/SATA
   Controller Model                         : Adaptec 3405
   Controller Serial Number                 : 8C421XXXXXX
   Physical Slot                            : 3
   Temperature                              : 47 C/ 116 F (Normal)
   Installed memory                         : 128 MB
   Copyback                                 : Disabled
   Background consistency check             : Disabled
   Automatic Failover                       : Enabled
   Global task priority                     : High
   Stayawake period                         : Disabled
   Spinup limit internal drives             : 0
   Spinup limit external drives             : 0
   Defunct disk drive count                 : 0
   Logical devices/Failed/Degraded          : 1/0/0
   NCQ status                               : Enabled
   --------------------------------------------------------
   Controller Version Information
   --------------------------------------------------------
   BIOS                                     : 5.2-0 (17342)
   Firmware                                 : 5.2-0 (17342)
   Driver                                   : 1.2-1 (29800)
   Boot Flash                               : 5.2-0 (17342)
   --------------------------------------------------------
   Controller Battery Information
   --------------------------------------------------------
   Status                                   : Charging
   Over temperature                         : No
   Capacity remaining                       : 98 percent
   Time remaining (at current draw)         : 5 days, 10 hours, 48 minutes

----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
   Logical device name                      : R5
   RAID level                               : 5
   Status of logical device                 : Optimal
   Size                                     : 420290 MB
   Stripe-unit size                         : 256 KB
   Read-cache mode                          : Enabled
   Write-cache mode                         : Enabled (write-back)
   Write-cache setting                      : Enabled (write-back)
   Partitioned                              : No
   Protected by Hot-Spare                   : No
   Bootable                                 : Yes
   Failed stripes                           : No
   Power settings                           : Disabled
   --------------------------------------------------------
   Logical device segment information
   --------------------------------------------------------
   Segment 0                                : Present (Controller:1,Enclosure:0,Slot:0)         BJA0PAXXXXXX
   Segment 1                                : Present (Controller:1,Enclosure:0,Slot:1)         BJA0PAXXXXXX
   Segment 2                                : Present (Controller:1,Enclosure:0,Slot:2)         BJA0PAXXXXXX
   Segment 3                                : Present (Controller:1,Enclosure:0,Slot:3)         BJA0PAXXXXXX

----------------------------------------------------------------------
Physical Device information
----------------------------------------------------------------------
      Device #0
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,0(0:0)
         Reported Location                  : Enclosure 0, Slot 0
         Reported ESD(T:L)                  : 2,0(0:0)
         Vendor                             : FUJITSU
         Model                              : MBA3147RC
         Firmware                           : 0103
         Serial number                      : BJA0PAXXXXXX
         World-wide name                    : 500000E115XXXXXX
         Size                               : 140272 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Unknown
         Supported Power States             : Full rpm
      Device #1
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,1(1:0)
         Reported Location                  : Enclosure 0, Slot 1
         Reported ESD(T:L)                  : 2,0(0:0)
         Vendor                             : FUJITSU
         Model                              : MBA3147RC
         Firmware                           : 0103
         Serial number                      : BJA0PAXXXXXX
         World-wide name                    : 500000E115XXXXXX
         Size                               : 140272 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Unknown
         Supported Power States             : Full rpm
      Device #2
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,2(2:0)
         Reported Location                  : Enclosure 0, Slot 2
         Reported ESD(T:L)                  : 2,0(0:0)
         Vendor                             : FUJITSU
         Model                              : MBA3147RC
         Firmware                           : 0103
         Serial number                      : BJA0PAXXXXXX
         World-wide name                    : 500000E115XXXXXX
         Size                               : 140272 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Unknown
         Supported Power States             : Full rpm
      Device #3
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device(T:L)       : 0,3(3:0)
         Reported Location                  : Enclosure 0, Slot 3
         Reported ESD(T:L)                  : 2,0(0:0)
         Vendor                             : FUJITSU
         Model                              : MBA3147RC
         Firmware                           : 0103
         Serial number                      : BJA0PAXXXXXX
         World-wide name                    : 500000E115XXXXXX
         Size                               : 140272 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
         S.M.A.R.T. warnings                : 0
         Power State                        : Unknown
         Supported Power States             : Full rpm
      Device #4
         Device is an Enclosure services device
         Reported Channel,Device(T:L)       : 2,0(0:0)
         Enclosure ID                       : 0
         Type                               : SES2
         Vendor                             : ADAPTEC
         Model                              : Virtual SGPIO
         Firmware                           : 0001
         Status of Enclosure services device
Posted in Vmware, Windows | Tagged , , , , , | 10 Comments