protected function extractCNFromDN($dn)
    {

        // explode the DN
        $splitArray = explode(',', $dn);
        $keyValue = array();

        // iterate over all elements
        foreach ($splitArray as $value) {
            $tempArray  = explode('=', $value);
            $keyValue[$tempArray[0]] = array();
            $keyValue[$tempArray[0]][] = $tempArray[1];
        }

        // return the CN
        return $keyValue[LdapLoginmodule::CN];
    }