Validating LDAP through QTP – 2

Moving from checking the user Existence from the previous post, we shall now try to understand how we can validate the user details present in the LDAP for a particular user.

So let us define a function getUserDetail(USerID,Field).

This will take the user-name and field as an input, and return Value of the field specified.

public Function getUserDetail(USerID,Field)

Set con = CreateObject("adodb.connection")
con.Open "Provider=ADsDSOObject;", "cn=root","password"

Select Case lcase(Field)
Case "firstname"
Field = "givenname"
Case "lastname"
Field = "sn"
Case "userdisabled"
Field = "ou"
Case "mobile"
Field = "mobile"
Case "email"
Field = "mail"
Case "phone"
Field = "homePhone"
Case "title"
Field = "businessCategory"
Case "password"
Field = "userPassword"
Case else
Reporter.ReportEvent micFail, "Invalid field; not found in ldap","Invalid field; not found in ldap"
Exit Function
End Select '
str= "select "& Field & " from 'LDAP://ldapserver:389/cn=users,dc=compName,dc=com' where ObjectClass='inetorgperson'and uid='"& UserName & "'"

Set rs = con.Execute(str)


Do While Not rs.EOF Or rs.BOF
ReturnValue = rs.Fields(Field)
If IsArray(ReturnValue) Then
val = ReturnValue(0)
For I = LBound(ReturnValue) + 1  To UBound(ReturnValue)
If ReturnValue(I) <> "" Then
val = val & "," & ReturnValue(I)
End If
Val = ReturnValue
End If

If TypeName(val) = "Byte()" then

end if
getUserDetail= Val & ""
End Function

Function OctetToHexStr(arrbytOctet)
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr &  Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
End Function

This function can fetch most of the basic fields such as FirstName, LastName, Phone.. etc. It can also fetch the password, but will be encycpted.

Most of the field updates can be validated with this function, And even Password reset can validated with simple logic as below.

/*      code to click on reset password button        */

if oldpwd = newpwd then
   Reporter.ReportEvent micFail, "Reset Password failed in LDAP","Reset Password failed in LDAP"
   Reporter.ReportEvent micPass, "Reset Password passed in LDAP","Reset Password passed in LDAP"

PS: Fields that we can query are limited the basic fields, And not any user defined fields.


Validating LDAP through QTP – 1

For the complete and Good Test Coverage, we usually cover the UI check, DB check as part of the automation. One more area which we more over tried to have a check is the LDAP. All user related information such as UserName, FirstName, mail-id, password, contact information are stored in LDAP Securely. I will we explain how we can Automate The LDAP tests with this series of Post.

Firstly, we shall try to understand how we can communicate with LDAP through QTP/VB scripts. LDAP internally have its own Database, which we can query the information. The process is simple as in the case of Database query. we first establish a connection, query the information. process the output.

As an example, we will define a function getDNofUser(username).

This will take the user-name as an input, and return empty string if the user doesn’t exist, or a complete Distinguished name of that user.

public Function getDNofUser(UserName)
 Set con = CreateObject("adodb.connection")
 con.Open "Provider=ADsDSOObject;", "cn=root", "password"
 sql = "select cn from 'LDAP://ldapserver:389/cn=users,dc=compName,dc=com' 
where ObjectClass='inetorgperson'and uid='"& UserName & "'"

 Set rs = con.Execute(sql)

 Do until rs.EOF
 ReturnValue = rs.Fields(0)
 If IsArray(ReturnValue) Then
 val = "cn=" & ReturnValue(0) & ",cn=users,dc=compName,dc=com"
 Val = "cn=" & ReturnValue & ",cn=users,dc=compName,dc=com"
 End If
 getDNofUser = val
End Function

The line

con.Open "Provider=ADsDSOObject;", "cn=root", "password" 

creates a connection object, we have to provide the LDAP credentials here. It need not be cn=root alway, It can be any user with read permission to the directory structure.

The line

sql = "select cn from 'LDAP://ldapserver:389/cn=users,dc=compName,dc=com' 
where ObjectClass='inetorgperson'and uid='"& UserName & "'"

is the actually query from which we would be fetching the detail from.

Note that in from clause, we are providing the ldap details: servername, portnumber, user Container and baseDN. In the where clause we are specifying the objectclass the user belong and the uid we are interested.

Once we execute this sql we will get the recordset. Little processing it we will be able to validate the user is present or not in the LDAP. So the Create User Sanity Test Case will Pass!! 🙂

Indian Languages on Andriod

Continuing  with Android R&D, I have now explored how font rendering works on Android.  If I am not wrong, Due to the internal memory limitation, Android don’t support all the languages. Only Latin bases languages are supported officially. Android uses UTF-8 standard for encoding. UTF-8 is the universal, and support all the languages and scripts.

Andriod have its own fonts and stored in /system/fonts directory.  This directory include the following fonts

  • DroidSans.ttf
  • DroidSans-Bold.ttf
  • DroidSansFallback.ttf
  • DroidSansMono.ttf
  • DroidSerif-Bold.ttf
  • DroidSerif-BoldItalic.ttf
  • DroidSerif-Italic.ttf
  • DroidSerif-Regular.ttf

As the names suggest, it support sans and serif font with bold, italic and mono spaced fonts. All these expect DroidSansFallback.ttf support only Latin based. And to support other languages, DroidSansFallback is used. when the non Latin characters are found in a text, its glyphs will not be present in DroidSans.ttf, but andriod will fallback to DroidSansFallback.ttf to fetch the glyph and present it in the UI.

DroidSansFallback is not complete set, and don’t contain any Indian languages. But if we replace DroidSansFallback.ttf with some Indian Font, say Sampige.ttf (Kannada Unicode font) renamed as DroidSansFallback.ttf , It would render Kannada characters and you will be able to read Kannada websites, twitts, Messages, mails etc.

However android doesn’t support conjuncts (how one character can modify the next or previous), Due to which the complex rendering doesn’t work, But still readable.

When it comes to Indian Languages we have many. I have worked an them and came up a Single Font for all languages . You can find this font on xdadevelopers forum. We don’t have to replace all the fonts, just replace DroidSansFallback.ttf font with this font.

Check this blog to know how to replace. we need to root the phone first.

Here are the sample screen shots of my android phone(Xperia x10 mini) with font installed.

Update: Latest Firmware from Sony Ericsson and Samsung  support Devanagari and Bengali Fonts. And the good news is that, It now support conjuncts (how one character can modify the next or previous). And its Perfectly readable.

For other Languages. The above procedure still holds good.

Here are the screen captures..

Enhanced by Zemanta

Kannada In Computers

I have always been asked how to type in Kannada on computers. I though of sharing the methods on my blog. This holds good for other Indian languages as well.

Targeting at Windows first. They are about dozen ways to type in Kannada.  I am not going to explain all the ways but only target the easiest ways.

Enabling Indian Language Support

Before beginning, Your computer needs to enabled for the support of the languages.  To do this follow these steps for Windows XP

  1. Go to Control Panel
  2. Open Regional and Language options applet
  3. Click  on Languages tab.
  4. Check the option “Install files for complex scripts and right-to-left languages(including Thai)”

    Regional Settings

    Regional Settings

  5. click “Ok” on the alert, and then press “Details”
  6. check the option “Extend support of advanced text services to all programs”

    Regional Settings

    Regional Settings

  7. Finally, Click on “Apply” in all the dialogs.
  8. It may ask of the “Windows CD” and to restart. Do them accordingly and your XP support Indian Language.

Later Windows, Vista Windows 7, support Indian Language by Default.

Using the Tools

  • Predictive Input: These are the easiest way to type Kannada, they predict the words as you type. Browser versions are also available.
  1. Microsoft Indic Language Input
  2. Google IME
  • Non Predictive Input: These are classic way of typing based on keyboard layouts.
  1. BarahaIME
  2. Nudi
Enhanced by Zemanta

Top 20 Replies by Programmers when their programs do not work

20. “That’s weird…”

19. “It’s never done that before.”

18. “It worked yesterday.”

17. “How is that possible?”

16. “It must be a hardware problem.”

15. “What did you type in wrong to get it to crash?”

14. “There is something wrong in your data.”

13. “I haven’t touched that module in weeks!”

12. “You must have the wrong version.”

11. “It’s just some unlucky coincidence.”

10. “I can’t test everything!”

9. “THIS can’t be the source of THAT.”

8. “It works, but it hasn’t been tested.”

7. “Somebody must have changed my code.”

6. “Did you check for a virus on your system?”

5. “Even though it doesn’t work, how does it work?

4. “You can’t use that version on your system.”

3. “Why do you want to do it that way?”

2. “Where were you when the program blew up?”

And the Number One Reply by Programmers when their programs don’t work:

1. “It works on my machine.”

Funny Side Up

Gilbert’s Discovery:
Any attempt to use the new super glues results in the two pieces sticking to your thumb and index finger rather than to each other.
Rich bachelors should be heavily taxed.  It is not fair that some men should be happier than others.
— Oscar Wilde
If you can’t read this, blame a teacher.
You can fool some of the people some of the time, and some of the people all of the time, and that is sufficient.
Hildebrant’s Principle:
If you don’t know where you are going, any road will get you there.
Anyone can do any amount of work provided it isn’t the work he is supposed to be doing at the moment.
— Robert Benchley
Conjecture: All odd numbers are prime.
Mathematician’s Proof:
3 is prime.  5 is prime.  7 is prime.  By induction, all odd numbers are prime.
Physicist’s Proof:
3 is prime.  5 is prime.  7 is prime.  9 is experimental error.  11 is prime.  13 is prime …
Engineer’s Proof:
3 is prime.  5 is prime.  7 is prime.  9 is prime. 11 is prime.  13 is prime …
Computer Scientist’s Proof:
3 is prime.  3 is prime.  3 is prime.  3 is prime…
An apple a day makes 365 apples a year.
Q:      How did you get into artificial intelligence?
A:      Seemed logical — I didn’t have any real intelligence.
Workers of the world, arise!  You have nothing to lose but your chairs.
Love is staying up all night with a sick child, or a healthy adult.
A transistor protected by a fast-acting fuse will protect the fuse by blowing first.
We are all agreed that your theory is crazy.  The question which divides us is whether it is crazy enough to have a chance of being correct.  My own feeling is that it is not crazy enough.
— Niels Bohr
The best way to make a fire with two sticks is to make sure one of them is a match.
— Will Rogers
It is so stupid of modern civilisation to have given up believing in the devil when he is the only explanation of it.
— Ronald Knox, “Let Dons Delight”
High heels are a device invented by a woman who was tired of being kissed on the forehead.
Snoopy: No problem is so big that it can’t be run away from.
There are two times when a man doesn’t understand a woman — before marriage and after marriage.
Lawyer’s Rule:
When the law is against you, argue the facts.
When the facts are against you, argue the law.
When both are against you, call the other lawyer names.
If it happens once, it’s a bug.
If it happens twice, it’s a feature.
If it happens more than twice, it’s a design philosophy.
I’ve always felt sorry for people that don’t drink — remember,
when they wake up, that’s as good as they’re gonna feel all day!
He who knows not and knows that he knows not is ignorant.  Teach him.
He who knows not and knows not that he knows not is a fool.  Shun him.
He who knows and knows not that he knows is asleep.  Wake him.
Two men are in a hot-air balloon.  Soon, they find themselves lost in a canyon somewhere.  One of the three men says, “I’ve got an idea.  We can
call for help in this canyon and the echo will carry our voices to the end of the canyon.  Someone’s bound to hear us by then!”
So he leans over the basket and screams out, “Helllloooooo!  Where are we?”  (They hear the echo several times).
Fifteen minutes later, they hear this echoing voice: “Helllloooooo!
You’re lost!”
The shouter comments, “That must have been a mathematician.”
Puzzled, his friend asks, “Why do you say that?”
“For three reasons.  First, he took a long time to answer, second,
he was absolutely correct, and, third, his answer was absolutely useless.”
You will always find something in the last place you look.
Nothing lasts forever.
Where do I find nothing?
If someone had told me I would be Pope one day, I would have studied harder.
— Pope John Paul I
The marvels of today’s modern technology include the development of a soda can, when discarded will last forever … and a $7,000 car which
when properly cared for will rust out in two or three years.

Make your own widgets for Samsung star


This is a small simple tutorial, how you can make your own widgets.

Widgets: These are the small applications which lay on the screen, and serve some purpose, like display date, time, calendar etc….

Technically there are many types of widgets, which are application specific, where it can run.

Samsung star supports HTML Widgets. HTML in the sense, widgets are comprises of html pages(.html), style sheets(.css), java script(.cs) and image files.

These are not a big deal to learn these. As a computer student or a software professional, you can build your own widgets.

Moving further, let’s start with building a simple widget.

Firstly, define the purpose of your widgets: for the example, I always want a text on the screen, no matter if I change my wallpaper frequently. But I hate to edit all the wallpapers and add the text to them, and use as the wallpaper. Instead we can make the widget of that text and make use of it. Now you can place this widget where ever you like, and change wallpaper independently as you like.

Widgets are zipped archive files with extension “.wgt”

This archive contains the following files/folders

Config.xml – XML file, which stores the configurations of the widget

Index.html – html file which loads when it starts

Images – Folder containing the image file (png,jpg)

Js – Folder containing the javascript files

Css – Folder containing style sheet files


<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<widget xmlns="" 
<icon src="images/p.png"/>
 <content src="index.html"/>
 <access network="false"/>
  1. height: specify the height of the widget
  2. width: specify the width of the widget
  3. id: Random or unique value for your widget
  4. version: version of widgets, use to replace the older widgets
  5. Title: name of your widget
  6. description: little description
  7. icon: path to the image, which you want it to be the icon
  8. content src: html page to load
  9. access network: set whether it access network or not


In this folder, you can save your image files, used by your widget


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<body background="images/p.png" style="background-repeat:no-repeat">

This html page is the simplest one, it just loads an png image file for the background.


As this is a simple application, it doesn’t require style sheet and java scripts and folders are empty. If your widget requires them add them in these folders and link them in index.html

Next, zip all the these contents into a zip archive [], and change the extension to .wgt [mywidget.wgt]

Create an installer.html

<meta http-equiv="refresh" content="0; url=mywidget.wgt">

Finally, copy installer.html and mywidget.wgt to your star and install the widget by opening installer.html

You can download this widget here