I need to execute a logon script where I need to check if the user belongs to a OU specific.
I get the DN:
Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
And then I use the InStr
function to search the OU specific but alway get 0 as the position although the string to compare exists in the DN.
I think that the problem is that objSysInfo.UserName
retrieves a BSTR data and I need to convert to string but I don't know how.
This is the complete code:
On Error Resume Next
Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
WScript.Echo "DN: " & strUserDN
ouZaragoza="OU=Zaragoza"
ouGeneral="OU=General"
WScript.Echo InStr("OU=Informática",strUserDN)
And always get O as result