GessWurker1
Technical User
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
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