×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

problem with AD query, empty values and form field population

problem with AD query, empty values and form field population

problem with AD query, empty values and form field population

(OP)
Hi - I'm running into trouble with my AD query when an AD profile lacks a middle initial. Here's the vbscript snippet


strRSUser = "SELECT displayname,givenName,initials,sn,employeeID,postalcode,memberOf,objectCategory,physicaldeliveryofficename,mail,manager FROM 'LDAP://" & strDomain &"' WHERE samaccountname = '"& varUser &"' ORDER by name "
rsUser.Open strRSUser, connAD,1,1

' Make sure recordset is not empty (i.e. this is a valid user) and then set the session variables
If NOT (rsUser.BOF AND rsUser.EOF) Then
Dim varInitials
Session("userAccess") = 1
varEmail = rsUser.Fields.Item("mail").Value
varEmployeeID = rsUser.Fields.Item("employeeID").Value
varFirstName = rsUser.Fields.Item("givenName").Value
varInitials = rsUser.Fields.Item("initials").Value
varLastName = rsUser.Fields.Item("sn").Value
varOffice = rsUser.Fields.Item("physicaldeliveryofficename").Value
varInitialsChk = IsEmpty(varInitials)
Session.Timeout = 60

Else
Session("userAccess") = 0

' End valid user check
End If

My problem:

I need to account for the possibility that varInitials may be nonexistent. Haven't found a way to do it. Consequently, the javascript line below breaks for users without a middle initial in AD. So far, my only solution is to leave out varInitials entirely, but that's not ideal. When varInitials are present, I want to populate the from field with them:

"if(emptyString.test(theForm.ctl00$ctl00$mpcSingleContent$cntrlID_23172.value)) {" & vbCrLf & _
" theForm.ctl00$ctl00$mpcSingleContent$cntrlID_23172.value = """ + varLastName + ", " + varFirstName + " " + varInitials + """" & vbCrLf & _
"}" & vbCrLf & _

Who can help?

Thanks,

--Timothy

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close