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


It’s Saturday morning and Bob’s just about to set off on a round of golf, when he realizes that he forgot to tell his wife that the guy who fixes the washing machine is coming around at noon. So Bob heads back to the clubhouse and phones home.

“Hello?” says a little girl’s voice.

“Hi, honey, it’s Daddy,” says Bob. “Is Mommy near the phone?”

“No, Daddy. She’s upstairs in the bedroom with Uncle Frank.”

After a brief pause, Bob says, “But you haven’t got an Uncle Frank, honey!”

“Yes, I do, and he’s upstairs in the bedroom with Mommy!”

“Okay, then. Here’s what I want you do. Put down the phone, run upstairs and knock on the bedroom door and shout in to Mommy and Uncle Frank that my car’s just pulled up outside the house.”

“Okay, Daddy!” A few minutes later, the little girl comes back to the phone. “Well, I did what you said, Daddy.”

“And what happened?”

“Well, Mommy jumped out of bed with no clothes on and ran around screaming, then she tripped over the rug and went out the front window and now she’s all dead.”

“Oh, my God! What about Uncle Frank?”

“He jumped out of bed with no clothes on too, and he was all scared and he jumped out the back window into the swimming pool. But he must have forgot that last week you took out all the water to clean it, so he hit the bottom of the swimming pool and now he’s dead too.”

There is a long pause.

“Swimming pool? Is this 854-7039?”

Why did the chicken cross the road?

KINDERGARTEN TEACHER: To get to the other side.

ARISTOTLE: It is the nature of chickens to cross roads.

KARL MARX: It was a historical inevitability.

SADDAM HUSSEIN: This was an unprovoked act of rebellion and we were quite justified in dropping 50 tons of nerve gas on it.


CAPTAIN JAMES T. KIRK: To boldly go where no chicken has gone before.

ANDERSEN CONSULTING: Deregulation of the chicken’s side of the road was threatening its dominant market position. The chicken was faced with significant challenges to create and market. Andersen Consulting, in a partnering relationship with the client, helped the chicken by rethinking its physical distribution strategy and implementation processes. Using the Poultry Integration Model (PIM), Andersen helped the chicken use its skills, methodologies, knowledge, capital and experiences to align the chicken’s people, processes and technology in support of its overall strategy within a Program Management framework. Andersen Consulting convened a diverse cross-spectrum of road analysts and best chickens along with Anderson consultants with deep skills in the transportation industry to engage in a two-day itinerary of meetings in order to leverage their personal knowledge capital, both tacit and explicit, and to enable them to synergize with each other in order to achieve the implicit goals of delivering and value framework across the continuum of poultry cross-median processes. The meeting was held in a park-like setting, enabling and creating an impactful environment which was strategically based, industry-focused, and built upon a consistent, clear, and unified market message and aligned with the chicken’s mission, vision, and core values. This was conducive towards the creation of a total business integration solution. Andersen Consulting helped the chicken change to become more successful.

MARTIN LUTHER KING, JR.: I envision a world where all chickens will be free to cross roads without having their motives called into question.

MOSES: And God came down from the Heavens, and He said unto the chicken, “Thou shalt cross the road.” And the chicken crossed the road, and there was much rejoicing.

FOX MULDER: You saw it cross the road with your own eyes. How many more chickens have to cross the road before you believe it?

RICHARD M. NIXON: The chicken did not cross the road. I repeat, the chicken did NOT cross the road.

MACHIAVELLI: The point is that the chicken crossed the road. Who cares why? The end of crossing the road justifies whatever motive there was.

BILL GATES: I have just released the new Chicken Office 2000, which will not only cross roads, but will lay eggs, file your important documents, and balance your checkbook.

DARWIN: Chickens, over great periods of time, have been naturally selected in such a way that they are now genetically disposed to cross roads.

EINSTEIN: Whether the chicken crossed the road or the road moved beneath the chicken depends upon your frame of reference.

BUDDHA: Asking this question denies your own chicken nature.

CLINTON: I did not, and I repeat, I did not have any relations with the chicken.

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.”