LDAP authentication in WordPress

Requirements

Install LDAP
Install WordPress from 2.2 to 3.4 version

Steps

1. Create Users and Groups in LDAP.
2. Install wpDirAuth plugin in WordPress.
3. Configure wpDirAuth plugin. Steps to do this.
(i) Go to Directory Auth from settings menu.
(ii) Enable Directory Authentication to Yes if you want that WordPress authenticate LDAP users.
(iii) Requires SSL Login to Yes if you want WordPress login to do encryption.
(iv) Directory servers(Domain Controllers) means DNS or IP address. In my case I installed LDAP on my local server that is localhost.
(v) Account Filter means attribute of LDAP which authenticates WordPress login. In my case I chose cn(common name).
(vi) Base DN(distinguish name) contains the name of LDAP group of users you used to register in WordPress. In my case I have given ou=people,dc=navdeep,dc=bagga. Where ou=people is LDAP group of users.
(vii) Bind DN value contain admin of LDAP. Below given command displays the admin of your LDAP.

$ ldapsearch -x -b dc=debuntu,dc=local

In my case it is cn=admin,dc=navdeep,dc=bagga

(viii) Bind Password is a password of LDAP.

4. Save your settings by clicking on Update Options.
5. Go to Users menu and Click on ‘Add Directory Authenticated User’.
6. To register your LDAP user in WordPress, give filter attribute value in SSOID field which you have given in Account filter at the time you have configured plugin.In my case I have given name neha which is the value of cn in my LDAP. Define your role which you want to give to that member. Click on Add New User.
7. Open your login window in WordPress. Give ldap Username and password which you have registered in WordPress(step 6).

Configure gateway on ubuntu

Before configure gateway first install kannel

Configuration of gateway can be divided into two parts.

Bearerbox : bearerbox is a gateway, interface towards the phones. Its work is to keeping an eye on the gateway while it is running and use http interface to control the gateway.

smsbox : It handles sms gateway functionality. It contain sms-services, sendsms-user group which helps sms center to build.

sqlbox : (optional) sqlbox is used for DLR(delivery report) storage. Use to store logs of incoming and outgoing SMS in database.

Purpose of Using kannel : To send and receive sms for your application.

Requirements : GSM phone or modem (link to compatible.shtml)

Attach your phone or modem to the computer through USB cable.

Enter the following command in your terminal.

$ wvdialconf
 Note : run command with sudo user

If it display : No modem was detected.

Then your phone is not compatible with kannel.

If it display : Found an USB modem.

Then your phone is compatible with kannel.

Your connected device configuration written to /etc/wvdial.conf

Open wvdial.conf file in your favourite editor.

$ vim /etc/wvdial.conf

Value of Init1 ,Init2, Modem Type, Modem use in gateway configuration

Lets write configuration file for kannel.

Edit kannel.conf file on your desktop or anywhere you want in your file system.

core group is used for general bearerbox configuration. dlr-storage value is depend on which DBMS is used.

group = core
 admin-port = 13003
 admin-password =
 admin-allow-ip = "127.0.0.1"
 dlr-storage = mysql //where to store the logs of sms
 smsbox-port = 13016
 log-file = "/var/log/kannel/bearerbox.log"
 access-log = "/var/log/kannel/access.log"
 box-allow-ip = "127.0.0.1"
 log-level = 0

smsc group include all variables which used to set SMS center in kannel. smsc-id value is name of device which is connected. modemtype and device change according to Modem value in wvdial.conf file

group = smsc
 smsc-id = Nokia
 smsc = at
 modemtype = USB Modem
 device= /dev/ttyACM0
 my-number = +919888888887
 connect-allow-ip = 127.0.0.1
 sim-buffering = false
 log-level = 0

mysql-connection group is used when mysql database is used to store data values. database,username,password variables values are database name,database username and password respectively.

group = mysql-connection
 id = mydlr
 host = localhost
 username = boot
 password = abc
 database = key
group = dlr-db
 id = mydlr
 table = dlr
 field-smsc = smsc
 field-timestamp = ts
 field-source=source
 field-destination = destination
 field-service = service
 field-url = url
 field-mask = mask
 field-status = status
 field-boxc-id = boxc

Modem group is used to define Modem configuration. init- string variable value change according to Init value in wvdial.conf file

group = modems
 id = Nokia
 name = Nokia
 detect-string = "Nokia"
 init-string = "ATZ"
 init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
 message-storage = SM
 message-start = 0

smsbox group must define to use SMS Kannel

group = smsbox
 smsbox-id = mysmsbox
 bearerbox-host = localhost //hostname
 bearerbox-port = 13020
 sendsms-port = 13013
 global-sender = +919888888887 //your modem number
 access-log = "/var/log/kannel/smsbox-access.log"
 log-file = "/var/log/kannel/smsbox.log"
 log-level = 0
 mo-recode = true

smsbox route group is develop an interface between smsbox and bearerbox.

group = smsbox-route
 smsbox-id = mysmsbox
 smsc-id = Nokia

sendsms-user group is used to push SMS through browser. Variables username and password are used for authentication purpose.

group = sendsms-user
 username =
 password =
 concatenation= true
 max-messages = 10000

sms-service group is provide services to incoming SMS. Accepted-smsc variable means which SMS center used to accept as incoming SMS.

group = sms-service
 keyword-regex = .*
 catch-all = true
 accepted-smsc = Nokia
 max-messages = 99
 get-url = "http://localhost/api/sms.php?phone=%p&text=%a"

Edit sqlbox.conf file where your kannel.conf file is placed.

sqlbox group used to tell kannel about sms log table and insert table. The sql-insert-table is used to store SMS which we want to send and sql-log-table is show logs of sms which are send through kannel and log of delivery reports.

group = sqlbox
id = sqlbox-db
global-sender = "+919888888887"
bearerbox-host = localhost
bearerbox-port = 13016
smsbox-port = 13020
smsbox-port-ssl = false
sql-log-table = sent_sms
sql-insert-table = send_sms
log-file = "/var/log/kannel/kannel-sqlbox.log"
log-level = 0

mysql-connection group explained before

group = mysql-connection
id = sqlbox-db
host = localhost
username = boot
password = abc
database = key

Lets send SMS through kannel through http(browser) and application. Excited 😉

Start kannel service: Run these commands on seperate Terminals sequentially with sudo user.

$ bearerbox -v 1 kannel.conf
$ sqlbox -v 1 sqlbox.conf
$ smsbox -v 1 kannel.conf

Set verbosity level
0 is ‘debug’.
1 is ‘info.
2 ‘warning’.
3 ‘error’.
4 ‘panic’.

Send SMS through browser : Open your favorite browser and type below given on address bar.

http://localhost:13003/cgi-bin/sendsms?username=&password=&to=0123456&text=Hello+world

13001 is an admin-port number which is defined in core group.
username and password value which is define in sendsms-user group.
to value contain phone number to whom we want to send SMS.
text value contain content of SMS.

Send SMS through application : To send through application is just do one entry in send_sms table of defined database in config files.

Method : Write sql query which insert sender, receive number and message data in send_sms table. kannel automatically check send_sms table and send SMS.

sql code of tables

sent_sms

send_sms

All the Best!