LeverN
asked on
Error (0x80020009) Exception Occurred when using GetObject
I get this error, I believe, because there is no value being passed to the function.
Here is my code. I can call this function using VBScript easily when running a VBS but, when I insert into ASP and run from IIS server, I get the error. After some troubleshooting, it appears that my function isn't receiving the variable that I passed to it. I tested this by setting the sEMAIL within the function and it runs swimmingly. This function is defined at the top most portion of my ASP and I call it from further down once I've processed the form properties. All help is appreciated!!
Function CheckEmail(sEmail)
' sEmail = "nsmith@me.com"
dim SQLQuery, Conn, rs, objuser
SQLQuery = "SELECT name, distinguishedName FROM 'LDAP://DC=nac,DC=me,DC=co m' WHERE objectCategory='Person' and objectClass='user' and mail='" & sEmail & "'"
Set Conn = CreateObject("ADODB.Connec tion")
Conn.Provider = "ADsDSOObject"
Conn.Open "Active Directory Provider"
Set rs = Conn.Execute(SQLQuery)
set objuser = Getobject("LDAP://" & rs("distinguishedName"))
CheckEmail = objuser.mail
end Function
Here is how I call the function:
strsemail = "nsmith@me.com"
validEmail = ""
validEmail = CheckEmail(strsemail)
if validEmail = "" then
msgText = "ERROR! The Supervisor's Email cannot be validated"
end if
Here is my code. I can call this function using VBScript easily when running a VBS but, when I insert into ASP and run from IIS server, I get the error. After some troubleshooting, it appears that my function isn't receiving the variable that I passed to it. I tested this by setting the sEMAIL within the function and it runs swimmingly. This function is defined at the top most portion of my ASP and I call it from further down once I've processed the form properties. All help is appreciated!!
Function CheckEmail(sEmail)
' sEmail = "nsmith@me.com"
dim SQLQuery, Conn, rs, objuser
SQLQuery = "SELECT name, distinguishedName FROM 'LDAP://DC=nac,DC=me,DC=co
Set Conn = CreateObject("ADODB.Connec
Conn.Provider = "ADsDSOObject"
Conn.Open "Active Directory Provider"
Set rs = Conn.Execute(SQLQuery)
set objuser = Getobject("LDAP://" & rs("distinguishedName"))
CheckEmail = objuser.mail
end Function
Here is how I call the function:
strsemail = "nsmith@me.com"
validEmail = ""
validEmail = CheckEmail(strsemail)
if validEmail = "" then
msgText = "ERROR! The Supervisor's Email cannot be validated"
end if
ASKER
Thanks Dex* but, I don't think that perms are the problem because, as I said, when I set the value within the function, everything works properly. It seems like the value isn't being passed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
kblack15217:
> I have seen this problem before, and it is wierd. But I solved it by adding
> a byRef to the function parameter.
>
> Function CheckEmail(byref sEmail)
If that works, then this is really odd. But in this case, you don't WANT to ByRef, you want ByVal (you should only use ByRef if you want to change the value of the parameter).
If adding ByRef fixes the problem, you should try ByVal too, because that's really what you want. But in VBS, it defaults to ByVal, so you shouldn't need to specify it. Very odd.
Dex*
> I have seen this problem before, and it is wierd. But I solved it by adding
> a byRef to the function parameter.
>
> Function CheckEmail(byref sEmail)
If that works, then this is really odd. But in this case, you don't WANT to ByRef, you want ByVal (you should only use ByRef if you want to change the value of the parameter).
If adding ByRef fixes the problem, you should try ByVal too, because that's really what you want. But in VBS, it defaults to ByVal, so you shouldn't need to specify it. Very odd.
Dex*
Yes, as mentioned, its very odd. I have no explanation why it fixed my problem.
And it only fixed my problem with byref.
ASKER
Thanks to both of you. I added the ByRef AND checked the contents of the RS before attempting the LDAP call. If RS is EOF, then I skip the call and return nothing from the function. This worked. So, based upon Dex* suggestion, I removed the ByRef and it is still passing the variable successfully.
Pretty wacky - I don't get it either ... but, many thanks!
here is the final version of the code:
Function CheckEmail(sEmail)
SQLQuery = "SELECT name, distinguishedName FROM 'LDAP://DC=nac,DC=me,DC=co m' WHERE objectCategory='Person' and objectClass='user' and mail='" & sEmail & "'"
Set Conn = CreateObject("ADODB.Connec tion")
Conn.Provider = "ADsDSOObject"
Conn.Open "Active Directory Provider"
Set rs = Conn.Execute(SQLQuery)
if not rs.eof then
set objuser = Getobject("LDAP://" & rs("distinguishedName"))
CheckEmail = objuser.mail
else
checkEmail = ""
end if
end Function
Pretty wacky - I don't get it either ... but, many thanks!
here is the final version of the code:
Function CheckEmail(sEmail)
SQLQuery = "SELECT name, distinguishedName FROM 'LDAP://DC=nac,DC=me,DC=co
Set Conn = CreateObject("ADODB.Connec
Conn.Provider = "ADsDSOObject"
Conn.Open "Active Directory Provider"
Set rs = Conn.Execute(SQLQuery)
if not rs.eof then
set objuser = Getobject("LDAP://" & rs("distinguishedName"))
CheckEmail = objuser.mail
else
checkEmail = ""
end if
end Function
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: Dexstar {http:#9689410}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
vnvk
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: Dexstar {http:#9689410}
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
vnvk
EE Cleanup Volunteer
I am sorry for the error, its actually
Yeah, that's cool with me.
Peace,
D*
Peace,
D*
> I can call this function using VBScript easily when running a VBS but, when
> I insert into ASP and run from IIS server, I get the error.
Could it be a permissions issue? Maybe the IUSR_ account doesn't have access to create the object.
You can check it by setting the NTFS permissions on your ASP file so that the IUSR_ doesn't even have read access to it. Then when you request the page, IIS will prompt the user for a name/password. Enter the same user information that you use when you run the VBScript and it works.
Then the script will run as that user, and that should have the proper rights.
Hope that helps,
Dex*