Hello everybody!

Updating to an Umbraco site, which is now primarly going to be a blog about useful and interesting software development related things.

Historic articles and software has been kept and more will be added in due course.

View the Archive...

Archive for tag: H-Sphere

H-Sphere XML API - Create Mailboxes

This is the first of a few simple perl script that I wrote to help with some admin tasks, it uses the H-Sphere XML API to create mailboxes for existing accounts, the other scripts will be posted shortly.

#!/usr/bin/perl

use DBI(); 
#use strict;
use SOAP::Lite;
use Data::Dumper;

$serviceuri = 'cp.your-server.com';
use Env;

addEmail ('Account#', 'AccountUserName', 'AccountPassword', 'MAILBOX', 'MAILBOXPASSWORD', 'domain.com');


sub addEmail {

        my $account = $_[0];
        my $login = $_[1];
        my $password = $_[2];
        my $email = $_[3];
        my $pass = $_[4];
        my $domain = $_[5];


        # generate authtoken
        my $authtoken = SOAP::Data->name('at' => 
                \SOAP::Data->value(
                        SOAP::Data->type('int')->name('accountId' => $account),
                        SOAP::Data->type('string')->name('login' => $login),
                        SOAP::Data->type('string')->name('password' => $password)
                        )
                );

        my $request = new SOAP::Lite;
        $request->proxy("http://$serviceuri:8180/psoft/servlet/MailServices.jws");
        $request->uri('MailServices');

        my $result = $request->addMailbox ($authtoken,  SOAP::Data->type('string' => $email),
                                                        SOAP::Data->type('string' => $domain),
                                                        SOAP::Data->type('string' => $pass),
                                                        SOAP::Data->type('string' => ""));
        if ($result->fault) {
                printf "2 - ($account) there was an error, %s %s\n", $result->faultcode, $result->faultstring;
        }

print "\n";
}

H-Sphere password checker

Hspwchk2 SmallThis application will check for weak passwords and can optionally email clients with relevant details.

A PHP script provides the relevant data to the Windows based application - the script has built in security so it will only respond to certain IPs, requires a password that you set and only runs over https, you can of course also add your own further security via firewalls etc.

Some highlights...

  • Check for only alpha/numeric/alphanumeric
  • Check for similar username and password
  • Check against your own dictionary
  • Check against any combination of FTP, Mailbox, CP, MySQL, PgSQL, MSSQL passwords
  • Email clients who's password weakness score is too high with your own templated mail

Requirements...Hspwchk1 Small

  • Windows Application
    • .NET v2 Framework
  • Webserver
    • PHP with IonCube
    • SSL (The script will only run over https)
    • Access to the control panel database (recommended via a restricted user id)
  • Mailserver
  • (if sending emails to clients)
    • SMTP AUTH

Kayako Login Share for H-Sphere

Here is how you can setup Kayako Login Share to work with your H-Sphere user accounts.

First log in to your H-Sphere database and run the following SQL - this is just to be more secure as you really don't want the loginshare php script accessing your hsphere DB with a high privilege user account. So we create a view that only feeds back username and md5hash of password - and setup a new user to access this view.

CREATE VIEW public.kayakologinshare (username, pass, email, name, lastname )
AS
select distinct users.username,
md5(users.password) as pass,
email,
name,
last_name as lastname
from contact_info,
accounts,
user_account,
users
where contact_info.id = accounts.ci_id
and accounts.id = user_account.account_id
and user_account.user_id = users.id
and users.reseller_id = 1;

CREATE USER "kayakologinshare" PASSWORD 'STRONGPASSWORDHERE';

GRANT SELECT ON "public"."kayakologinshare" TO "kayakologinshare";

If you have the full version with source code

I personaly know this way works as I have implemented it - Next you need to edit your /includes/LoginShare/loginshare.config.php and add the following lines...

define("LOGINAPI_HS",108);
$_LOGINAPI[LOGINAPI_HS] = array("title" => "H-Sphere login", "include" =>"hs.login.php");

NOTE : where 108 is in the first line above, this needs to be an usused number in the loginshare.config.php file, so make sure 108 is not already used otherwise change it.

Now download the zip file below and place the unzipped hs.login.php file in the /includes/LoginShare/ folder.

If you have the leased version without access to source code

This way will work as well, but I have not personally tried it, although I know others have with success. Unzip the file below and rename the file to hsphere.login.php and upload it to your /includes/LoginShare/ folder overwriting the existing file that is already there.

Finally...

When you have done this you can login to your Kayako admin screen and enter the DB details for kayakologinshare as above and then assign that login share to your template group.

You do also need to make sure that your the CP Postgre Server will accept connections from the server running Kayako
NOTE:Replace 10.11.12.13 with your server IP that is running Kayako

echo 'host all all 10.11.12.13 255.255.255.255 password' >> /var/lib/pgsql/data/pg_hba.conf

You also need to make sure that your firewall will allow access, eg if you are running iptables this should work.
NOTE:Replace 10.11.12.13 with your server IP that is running Kayako

iptables -I INPUT -s 10.11.12.13 -p tcp --dport 5432 -j ACCEPT