Solved

Error (0x80020009) Exception Occurred when using GetObject

Posted on 2003-11-05
13
3,653 Views
Last Modified: 2008-03-10
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=com' WHERE      objectCategory='Person'      and      objectClass='user' and mail='" & sEmail & "'"
      Set      Conn = CreateObject("ADODB.Connection")
      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

0
Comment
Question by:LeverN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9689240
LeverN:

> 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*
0
 

Author Comment

by:LeverN
ID: 9689308
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.
0
 
LVL 4

Accepted Solution

by:
kblack15217 earned 125 total points
ID: 9689366
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)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Assisted Solution

by:Dexstar
Dexstar earned 125 total points
ID: 9689410
Okay, I misread that...  Yeah, doesn't look like permissions then.

Do you have OPTION EXPLICIT turned on?  Sometimes that helps in finding issues like this.

I would debug it by printing (Response.Write) the value of sEmail inside of the function.  I would also output the value of SQLQuery, just to be extra sure.  And while you're at it, print out the value of rs("distinguishedName") too.

While this won't fix your issue, it will get rid of the error...  You should check the results of "Conn.Execute(SQLQuery)" before issuing the CreateObject command.  I would do this by making sure the value of
   rs("distinguishedName") and making sure it isn't empty.

D*
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9689432
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*
0
 
LVL 4

Expert Comment

by:kblack15217
ID: 9689511
Yes, as mentioned, its very odd.   I have no explanation why it fixed my problem.
0
 
LVL 4

Expert Comment

by:kblack15217
ID: 9689515
And it only fixed my problem with byref.
0
 

Author Comment

by:LeverN
ID: 9689547
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=com' WHERE      objectCategory='Person'      and      objectClass='user' and mail='" & sEmail & "'"
      Set      Conn = CreateObject("ADODB.Connection")
      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

0
 
LVL 7

Expert Comment

by:vnvk
ID: 11867860
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
0
 
LVL 7

Expert Comment

by:vnvk
ID: 11867865
I am sorry for the error, its actually

0
 
LVL 7

Expert Comment

by:vnvk
ID: 11867868
Split: kblack15217 {http:#9689366} & Dexstar {http:#9689410}

0
 
LVL 19

Expert Comment

by:Dexstar
ID: 11867932
Yeah, that's cool with me.

Peace,
D*
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FileUp - Classic ASP 5 27
ASP/VB email question 4 71
Record locking on classic ASP 3 59
add 'N to prepared ASP/VB insert statement 1 33
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question