How to Install Zabbix Monitoring on Ubuntu Server 16.04.2 LTS

Step by step to Install Zabbix 3.0 on Ubuntu Server 16.04.2 LTS:

  1. Install Ubuntu, open terminal and login with Root
    su –
  2. Update the System
    apt-get update
  3. Install LAMP Server
    apt-get install lamp-server^
  4. Add Zabbix Server Repositories to Ubuntu 16.04
    dpkg -i zabbix-release_3.0-1+xenial_all.deb
    apt-get update
  5. Install Zabbix Server
    apt-get install zabbix-server-mysql zabbix-frontend-php
  6. Create database for Zabbix Server
    mysql -u root -p
    CREATE DATABASE zabbixdb;
    GRANT ALL on zabbixdb.* to zabbix@localhost IDENTIFIED BY ‘yourpassword’;
  7. Restart zabbix database schema in newly created database
    cd /usr/share/doc/zabbix-server-mysql
    zcat create.sql.gz | mysql -u root -p zabbixdb
  8. Edit Zabbix Configuration File
    nano /etc/zabbix/zabbix_server.conf

    Update the following

  9. Change PHP timezone

    cd /etc/php/7.0/apache2
    nano php.ini

    date.timezone= Europe/London

  10. Install PHP Extensions and MIB

    apt-get install php7.0-xml
    apt-get install php7.0-bcmath
    apt-get install php7.0-mbstring
    apt-get install snmp-mibs-downloader

  11. Restart Services
    service apache2 restart
    service zabbix-server restart
  12. Start Zabbix Server Web Installer
    Click Next
  13. Log into Zabbix
    username: admin
    password: zabbix

I suggest you read up on Zabbix documentation and specifically the concepts and definitions. In the next post I will cover creating users, monitoring Windows OS, network devices, ping and tcp port monitoring and setting up email alerts.


ASP.NET Web Pages code behind and seperation of logic

ASP.NET Web Pages are ASP.NET sites without models, views, controllers, or project files. Now you may think that’s just like Classic ASP, or PHP?. It’s the full power and speed of the .NET with full syntax of C#. It’s simple, lightweight, fast, super powerful, and I am surprised more people don’t use it.

How to code behind, seperate logic or Object Oriented programming in web pages?

Right click onto your website > Add > New Folder and name is App_Code. This is the folder that will contain all your class files.

 Create a new class file in this folder called “Product.cs”



Copy the following code in this file:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class Product
    public int id { get; set; }
    public string desc { get; set; }
    public double price { get; set; }

    public Product()

    //get product by id
    public void getProductByID(int id)
    { = 1;
        this.desc = "ASP.NET Web Pages";
        this.price = 9.99;

This is an example of a class called Product which has 3 properties id, desc and price, a method which would normally get the data from database which we will cover a bit later.

Now create a new Web Page (Razor View cshtml) or in Default.cshtml copy the following

    Product myProduct = new Product();

    catch { <p>Invalid product ID</p>}
    <p>Desc: @myProduct.desc</p>
    <p>Price: @myProduct.price</p>

So this is our Razor view file equivalent of “.asp” or “.php” page which would have html and C# code. The first line creates a new instance of the object Product, we then invoke the method getProductByID which will set the hardcoded values to the object and this is what will be in output. Additionally, just to give you an idea, we are retrieving the ID from Request, try to parse it and provide it to the method.



 Resize images

 public static Image ResizeImage(Image image, Size size, bool preserveAspectRatio = true)
        int newWidth;
        int newHeight;
        if (preserveAspectRatio)
            int originalWidth = image.Width;
            int originalHeight = image.Height;
            float percentWidth = (float)size.Width / (float)originalWidth;
            float percentHeight = (float)size.Height / (float)originalHeight;
            float percent = percentHeight > percentWidth ? percentHeight : percentWidth;
            newWidth = (int)(originalWidth * percent);
            newHeight = (int)(originalHeight * percent);
            newWidth = size.Width;
            newHeight = size.Height;
        Image newImage = new Bitmap(newWidth, newHeight);
        using (Graphics graphicsHandle = Graphics.FromImage(newImage))
            graphicsHandle.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphicsHandle.DrawImage(image, 0, 0, newWidth, newHeight);
        return newImage;



//image from url
Image original = Image.FromFile("/Images/test.jpg");

//do the resize only if the original width is greater than 500
if (original.Width > 500) 
   Image resized = ResizeImage(original, new Size(500, 500));
   MemoryStream memStream = new MemoryStream();
   resized.Save("/Images/test-resized.jpg", ImageFormat.Jpeg);

 More to come…

Office 365 add shared mailbox to mobile device

Office 365 shared mailboxes do not require a license so autodiscover and ActiveSync will not work and the mailbox will not be accessible on a mobile device.

There are two ways to get around this problem:

1) Re-create the mailbox

Backup, delete and re-create the shared mailbox as regular licensed account. Restore your emails from backup and setup appropriate permissions.

2) Convert shared mailbox to regular mailbox

You will need Windows PowerShell to do this so install form below link if required:

1) Launch Windows PowerShell (Run as Administrator)

****If this is your first time connecting to O365 from your computer, please run the following command first before proceeding to step 2:

Set-ExecutionPolicy Unrestricted

The execution policy helps protect you from scripts that you do not trust. But we need it to be unrestricted so we can run commands. Enter “Y” and proceed to step 2 below.

2) Enter command

$cred = Get-Credential

Enter the credentials of an administrator account in the O365 Company to login.

3) Issue the following command to create a connection.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $cred -Authentication Basic -AllowRedirection

4) Create session

Import-PSSession $Session

Finally, this is the command you need to execute to convert the mailbox from shared to regular, replace with the email address

Set-Mailbox -Type Regular

After running the above command and modified the mailbox as Regular, go in the admin section, reset the credential of the user. Login to your mobile device now with full email address.



Office 365 and outlook 2010 password never expire

If you are using Office 365 with Outlook 2010, one of the problems you may face at a certain point is the password expiry.

There is no notification to user in outlook 2010 about the password expired, instead you will see a message saying “server is unavailable”. When you attempt to log into Outlook Web App, this is when you realise the password has expired. There is no way to change the password directly from outlook 2010.

This was a real problem for us as we now had to spend next few hours with users complaining and resetting passwords. Once the password was reset, the user has to first login to Outlook Web App and change the password. Doing this every 3 months when the password expire is ludicrous so I am going to show you how to set the passwords to never expire.

Firstly, Microsoft has now released an update to show notification in outlook. If you want the passwords to expire and your users are comfortable to change the passwords every so often then follow this link:

Office 365 Password Never Expire

We will be using the Microsoft Online Services Module for Power Shell, It can be downloaded from the following link:

Power Shell resembles a command prompt client and through the Microsoft Online Services Powershell Module you can access your Office 365 account and apply changes to it.

Once you have downloaded the module, please execute the following commands:

Import-Module MSOnline
$Creds = Get-Credential
Connect-MsolService -Credential $Creds

Command to check the policy for specific user:

Get-MSOLUser -UserPrincipalName | Select PasswordNeverExpires

Command to check the password never expire policies for all users:

Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires

To change the policy for one user, please use the following command:

Set-MsolUser -UserPrincipalName -PasswordNeverExpires $true

Command to change the policy for all users:

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true 

How to setup a complete PHP development environment on Ubuntu

So you have decided to build websites with PHP but where do you start? To start building websites in PHP you need In at least web server (such as Apache or IIS), PHP and a MySQL database. You can install these separately which can be tiresomely long so in this post I will show you how to achieve this quickly so can focus on building websites and learning PHP.

We are going to use an all-in-one solution called XAMPP which makes it so easy to install Apache, MySQL, PHP and Perl. I will also cover setting up Virtual Hosts with XAMPP so you can access the files from a local folder without the need to ftp.

* Ubuntu –

Although these instructions are for Ubuntu, the same procedure applies for Windows or Mac OS X.

1) Download XAMPP

2) Install XAMPP

In terminal >

sudo su

CD to the directory where you have downloaded the xampp

tar xvfz xampp-linux-1.7.7.tar.gz -C /opt

3) Configure Virtual Hosts

sudo gedit /opt/lampp/etc/httpd.conf

Look for Virtual hosts

# Virtual hosts

#Include etc/extra/httpd-vhosts.conf


# Virtual hosts

Include etc/extra/httpd-vhosts.conf

sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf

Add the following entries to the httpd-vhosts.conf file

DocumentRoot /opt/lampp/htdocs
ServerName localhost
<Directory " /opt/lampp/htdocs">
AllowOverride All
DocumentRoot /home/username/Desktop/website.localhost
ServerName website.localhost
<Directory "/home/username/Desktop/website.localhost">
AllowOverride All

The first entry is for xampp page so you can access the xampp web pages using http://localhost in your web browser for security or phpmyadmin etc. The second entry points to a folder on the Desktop named “website.localhost”, this is the folder that will contain your new website.

DocumentRoot is the path to your website folder. Server name is what you will type in your web browser to access this website. We also addtag that is also path to your website folder and give override all permission, this will enable you to use .htaccess file within your website.

Next we need to edit the hosts file to map the server to local IP so it can be resolved. There is already a localhost entry so we just add an entry for website.localhost

sudo gedit /etc/hosts

add the following line    website.localhost

Now create the folder “website.localhost” on your Desktop or according to your DocumentRoot and create an index.php file.

4) Start XAMPP

sudo su
/opt/lampp/lampp start

Finally, point your browser to http://localhost and you will see XAMPP for Linux webpage. Similarly, you should see your test page if you point your browser to http://website.localhost

Thats it! Your PHP development environment is now set up and you are ready to start developing PHP web applications.

Starting with Android Development – Setting up development environment

With the rise of smartphones and tablet computers powered by Android, Android Developer is an important skill to add your resume. I have just started this journey and so far I have learnt how to setup the development area which is what I am going to show you.

I expect you already know about Android and use a Linux distrubition. A foundation on Java Programming or any other programming language will also help. I suggest you read a little about Java Programming if you have no programming experience, mainly on the syntax, Object-oriented programming and using API documentation.


Install Eclipse from Ubuntu Software Center

This is a very simple step, providing you have Ubuntu installed, go to Ubuntu Software Centre and install Eclipse.

Add Software links for Indigo and ADT Plugin
Once you have eclipse installed, click on Help > Install New Software > click Add button

Name: Indigo

Name: ADT Plugin

Wait until Developer Tools option appears under Name, Tick it, Click Next and follow on screen instructions. Once installed, it will ask to restart so do it.
Install Android SDK
Once eclipse is running again, you should see “Welcome to Android Development” message
Make sure “Install new SDK” is selected, two tick boxes are ticked and select location where you want the android sdk installed. Follow the the wizard and finish installing the sdk.

Create Android Virtual Device

An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device so you can test your application for different hardware and android versions.

In eclipse go to Windows > AVD Manager > New > give it a name > target 2.1 and click on create AVD

All Done, we are ready to make our first application.

I would suggest to have a look at below sample tutorial as a starting point. Download the zip folder and extract it into your /home/yourname/workspace folder

click on File > New > Android project > Create project from existing source > point the location to /home/krutant/workspace/Notepadv1

Make sure you have the correct AVD setup for a sample project import. Earlier, We setup an AVD with target 2.1 which will not run for the Notepadv1 project as it requires target 2.3


Resize and watermark images in Ubuntu

In this post i am going to show you how to resize and watermark images in bulk for free, without additional software and through bash script that will work on majority of linux distributions. This is very useful for anyone who has to regularly resize and watermark pictures for websites or catalogues.

You will need ImageMagick, most linux distributions already have it installed.

sudo apt-get install imagemagick

If it is already installed, you should see this:

Reading package lists... Done

Building dependency tree

Reading state information... Done

imagemagick is already the newest version.

What is ImageMagick

It allows you create, edit and display images from command line.

It can read, convert and write images in a large variety of formats. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bézier curves can be added to images and stretched and rotated.


Shell script

Create a file called “” and open it in your favourite editor.

The first line we want to add is


This means that the script should be run in the bash shell.



These are our global variables.

# "*****************************************"

# "* Image Resize and Watermarking Script *"

# "* By *"

# "*****************************************"

The above is the disclaimer, please keep this in the file.

read -p "Watermark with file \""$WATERMARK"\" & resize all images to width "$resize"?  " prompt

Prompt user of the filename used to watermark and the size.

if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]


If the user keys in y or yes then

for each in *{.jpg,.jpeg,.JPG,.JPEG}


for each jepg or jpeg file

echo -n "Working on "$each" ..."

Output the file name to be resized and watermarked.

convert -resize $resize "$each" "$each" >> /dev/null

Convert command to resize the file to the width specified.

composite -gravity center -dissolve 100 $WATERMARK "$each" "$each" >> /dev/null

Composite command to place the watermark in center of the image.

echo "[Done]"


echo ""

read -p "Press Enter to exit ..."


exit 0


Above is the end section where we output “done”, wait for user to press enter before exiting.

Save it to your home directory, right click on the file, click properties, permissions tab and tick “Allow executing file as a program”

or type this in terminal

sudo chmod a+x ~/

To run it, copy and watermark.png file into any folder with images and then double click and select “run in terminal” or open terminal and type “./pathtofile/”

When you run it, you will see few errors because the script will try to resize and watermark file name “.jpg”. To fix this, add below line just above the “for each loop” to ignore nulls.

shopt -s nullglob

Thats it! This is very simple script but it does the job. There is alot of room for improvement such as adding more image types, ignoring the watermark.png file so it does not resize the actual watermark file and so on. The main commands are convert and composite, typing them in terminal will bring up many other options.

Here is the complete code:




# "*****************************************"

# "* Image Resize and Watermarking Script *"

# "* By *"

# "*****************************************"

read -p "Watermark with file \""$WATERMARK"\" & resize all images to width "$resize"? " prompt

if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]


echo ""

shopt -s nullglob

for each in *{.jpg,.jpeg,.JPG,.JPEG}


echo -n "Working on "$each" ..."

convert -resize $resize "$each" "$each" >> /dev/null

composite -gravity center -dissolve 100 $WATERMARK "$each" "$each" >> /dev/null

echo "[Done]"


echo ""

read -p "Press Enter to exit ..."


exit 0


Batch resize and rotate with Nautilus

In Terminal:

sudo apt-get install nautilus-image-converter

Once it is installed, restart your computer or restart Gnome

sudo /etc/init.d/gdm restart

Browse to the folder where you have your photos, right click the photos and you will see the options to “Resize Images” and “Rotate Images”. Once you select resize or rotate option, You will get options to perform the operations.

How to surf the web anonymously

If you think you are anonymous on the internet then think again, by simply connecting to the internet you share information about your computer, your geographical location and even web sites you have just visited.

Some of the information you have already given away:

What will anyone possibly do with this little information? but if you combine this with say your Facebook profile where you have given away your name, date of birth, email address and also your browsing habits i.e what websites you often visit, what you like to buy on internet etc, you have pretty much given it all away. Ever wondered how the ads on websites you visit relate to a recent search or purchase?

Before i tell you how to be anonymous, it is important to understand what an IP adress and proxy server is.

What is an IP address?


Internet Protocol (IP) address is a unique number assigned to devices connected to public Internet. Your internet router is assigned an IP address when it connects to Internet service provider. So your ISP can identify internet requests made by your router and can route the data to it. Similarly, your devices such as PCs and laptops connect to your router and are assigned a local ip address so the router can identify which device is making the request and where to route the data. So it is your internet router that is connected to the internet, has the public IP address that gives away the above information and shares this internet connection with all your devices.

What is Proxy Server?


An anonymous proxy serves as a middleman between your web browser and an end server. Instead of contacting the end server directly to get a Web page, the browser contacts the proxy, which forwards the request on to the end server. When the end server replies to the proxy, the proxy sends the reply on to the browser. No direct communication occurs between the client and the destination server, therefore it appears as if the HTTP request originated from the intermediate proxy server. The only way to trace the connection to the originating client would be to access the logs on the anonymous web proxy (if it keeps any). So an anonymous proxy server can protect your identity by stripping a request of all identifying information.


I could not have explained the above any better so credit where its due.

How to be anonymous?


We now understand what IP address is and what proxy server is so all we need to do is hide our IP address by using a proxy server so all the websites see the IP address of the proxy server that cannot be traced back to us.

There few ways of achieving this:

1) VPN


This is a paid service which lets you connect through a VPN to a server. Here is an example: There are many other websites offering similar service, whichever website you decide to buy from, ensure there are no logs kept by the server and all the data is encrypted.

2) Web Proxy


This is very simple, go to proxy website such as or and then typing the website you want to access in their search box. The only disadvantage is that there are ads above the website.

3) IP Proxies


First go to and find an IP address with good speed, connectivity and high anonymity level. Set the IP address and the port in your internet browser.

Firefox: Edit > Preferences > Advanced

Internet Explorer 8


Google Chrome: Options > Under the hood > Network > Change proxy settings > LAN settings > Use a proxy server > Advanced > HTTP

Opera: Tools > Preferences > Advanced > Network

You will have to regularly update this with an IP address that provides good connection and speed. There will be country specific restrictions e.g. if you set an IP from China, you will not be able to browse websites blocked in China.

If you need to anonymous for life threatening reasons than stick to VPN solution, otherwise use Web or IP proxy.

Remember, your IP is your ID!

Geany – A Perfect Web Development IDE

One of my favourite editor is Editplus. I have really liked this editor over the years because it is simple, lightweight, custom code completion is very easy to setup and you can modify remote files without having to upload / download through FTP.

Since moving to Linux, I’ve been looking for an alternative. I wanted it to be light-weight, easy code completion and remote file editing. I found many choices in the Linux world and majority of them open source. I tried gedit, kate, Quanta, Eclipse, gPHPEdit, BlueFish and Geany. All of these have their advantages and disadvantages and someone is bound to like one over the other. I won’t go into reviewing all of them and would suggest to try them out yourself. I preferred gedit and geany over the others.


gedit is fast and it does pretty much everything you want from an editor. It lets you edit remote files without any hassle. It is also a default text editor on many Linux distributions. I found a lot of problems with Code Completion. gedit auto complete files in XML format e.g. in /usr/share/gedit-2/plugins/snippets/html.xml is the snippets file for HTML. It was not an easy job converting my current snippets into an XML type. The following code is an example of what you would need in there to auto complete “br” tag.


    <description>SGML tag</description>

After spending over an hour setting up the XML snippet for HTML, CSS and PHP, I found that if you try to autocomplete PHP code when you have a HTML file open it would not work. So I merged the 3 xml files into /usr/share/gedit-2/plugins/snippets/global.xml. Adding autocomplete code in this file will work for any file type including unsaved and empty files.

So I migrated my autocomplete file from Editplus format to gedit xml file. After all the tedious work, I found that the auto complete would not always work and it was unreliable. I had to restart gedit many times to get it working.


This is one the the best editors out there, The more i used it the more i liked it. It is a very light-weight with many plugins and features.

It auto completes XML/HTML tags by default. In preferences > editor > completion, you can auto-close quotes and brackets:

Brackets ()

Curly brackets {}

Square brackets []

Single quotes ''

Double quotes ""

To add custom snippets, go to tools > configuration files > snippets.conf and it will open in another tab. This is the only file you need to modify for all your needs, the snippets are added into different sections. Anything under [default] will work on any file type and adding code in [PHP] section will work for php files only.

Here is an example adding br tag to autocomplete for HTML files:




br=<br />

How easy was that? The word before the “=” sign is what you will type and on pressing “tab”, everything after the “=” sign is what will be replaced with. Save and test it out in a new document. This is alot similar to Editplus and easier than gedit xml.

At present, there is no direct FTP support in Geany and there is no plug-in available. For linux users there is a way, if you go to tools > plugins manager > Tick File Browser and click on View > Tick “Show Sidebar. On the sidebar, click on “Files” and navigate to “yourhomedirectory. Right click and Tick “Show Hidden Files” and navigate to “.gvfs” directory which will show your ftp folder. You can now modify remote files locally.

I found this is a perfect alternative to Editplus and even better. It works on many platforms and its FREE. For Linux its easy download from Software Packages such as Ubuntu Software Centre and for windows Download Here.

Download Geany snippets and extras.

How to use Ubuntu at workplace by joining an Active Directory domain


  • Computer running Ubuntu (10.04 / 10.10 / 11.04)
  • Admin rights to join a computer to domain
  • likewise-open version

Updated : 8th September 2011

I have updated this guide to use the newer likewise-open version that works a lot better and is easier to setup.


sudo gedit /etc/nsswitch.conf

replace hosts line that reads

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

with below and save the file:

hosts:          files dns

In terminal, ping your fully qualified domain name (FQDN)

ping mydomain.local

or ping

If you cannot ping or it is the wrong IP address

sudo gedit /etc/hosts

Add your domain and ip address before the localhost entry mydomaina.local localhost

Save the file and Reboot.

Installing likewise-open

Download Likewise-open 32-bit or 64-bit package from the website:

Once downloaded, Open Terminal and type the following:

sudo bash Downloads/LikewiseOpen-

Answer “y” to the prompts

Once it is installed, you will see the Domain join GUI. Type in your domaina name and click Join. Enter Administrator username and password or an account that has permission to join computers to domain.

You will see a message saying “Restart required”. Before you reboot, add the domain user to sudoers and to login screen user list.

Adding users to sudoers

We will be editing /etc/sudoers file for this:

sudo gedit /etc/sudoers 

Look for the following line:

# Members of the admin group may gain root privileges  
%admin ALL=(ALL) ALL

Add a lines as explained below:

If you have set default domain

username ALL=(ALL) ALL  # Allow specific account to sudo
domain^admins ALL=(ALL) # Allow admin group
domain^users ALL=(ALL) ALL # Allow all domain users

if you are not using default domain then you have to include the domain name:

%mydomain\\yourusername ALL=(ALL) ALL
%mydomain\\domain^admins ALL=(ALL) ALL
%mydomain\\domain^users ALL=(ALL) ALL

Add domain username to login screen user list

sudo gedit /etc/gdm/custom.conf

Add the greeter part at the end of the file. Add your domain username to include section and any other you want to exclude.


You can then reboot and login with your domain account.

Likewise-open default shell problem, terminal showing $ prompt

When you run a terminal you will get a $ prompt and tab to autcomplete will not work. To fix this type the following in terminal

sudo /opt/likewise/bin/lwregshell

cd HKEY_THIS_MACHINE\Services\lsass\Parameters\Providers\ActiveDirectory

set_value LoginShellTemplate /bin/bash


Reboot once you have done the above.

Troubleshooting older version of Likewise-open:

Problems joining domain

If you see an error as below, it means the domain name entered is not valid

Error: DNS_ERROR_BAD_PACKET [code 0x0000251e]

A bad packet was received from a DNS server. Potentially the requested address
does not exist.

If Domain name typed in is correct but you get the following error:

Network name not found.. Failure to lookup a domain name ending in ".local" may be the result of configuring the local system's hostname resolution (or equivalent) to use Multi-cast DNS. Please refer to the Likewise manual at for more information.

Error code: ERROR_BAD_NET_NAME (0x00000043) Backtrace: main.c:341 src/djmodule.c:330 src/djauthinfo.c:722 src/djauthinfo.c:1146 Edit hosts file:

sudo gedit /etc/hosts

Add the following line after localhost entry mydomain.local

If you still get an error like :


open /etc/nsswitch.conf

sudo gedit /etc/nsswitch.conf

Change the “hosts” line so it reads

hosts:          files dns

Problems loggin in…

Ensure that you are typing the domainname/username or just the username according to default domain value.

The older versions of likewise-open has a problem where the networking starts after the likewise services. You will not be able to login at all without restarting likewise service and once you have managed to log in, on the next reboot you will be in offline mode. Opening network shares will prompt you for username, domain name and password.

To fix this, in terminal type:
Press Ctrl+Alt+F1 which will take you to tty and login with an account that can sudo.

sudo gedit /etc/rc.local

This will open rc.local file in gedit

Add below code before line “exit 0”

/etc/init.d/lwsmd restart

so your rc.local file should look:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

/etc/init.d/lwsmd restart

exit 0

Save and Reboot. This will restart the likewise services just before you login preventing the offline mode and authentication problems.