Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 713809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:00:12+00:00 2026-05-14T05:00:12+00:00

I am loosing my hair on VBScript. How the heck can I pass a

  • 0

I am loosing my hair on VBScript. How the heck can I pass a reference as return value of a function?

Currently my code looks like this:

Set objUser = FindUser("bendert")

REM Searches Directory for the User
Function FindUser(UserLoginName)
    Wscript.Echo "Querying AD to retrieve user-data" 

 Set objConnection = CreateObject("ADODB.Connection")
 objConnection.Open "Provider=ADsDSOObject;"

 Set objCommand = CreateObject("ADODB.Command")
 objCommand.ActiveConnection = objConnection

 'Get user Using LDAP/ADO.  There is an easier way
 'to bind to a user object using the WinNT provider,
 'but this way is a better for educational purposes
 Set oRoot = GetObject("LDAP://rootDSE")
 'work in the default domain
 sDomain = oRoot.Get("defaultNamingContext")
 Set oDomain = GetObject("LDAP://" & sDomain)
 sBase = "<" & oDomain.ADsPath & ">"
 'Only get data for login name requested
 sFilter = "(&(sAMAccountName="& UserLoginName &")(objectClass=user))"
 sAttribs = "adsPath"
 sDepth = "subTree"

 sQuery = sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth
 WScript.Echo "LDAP Query is:" & sQuery &""

 objCommand.CommandText=sQuery
 Set objRecordSet = objCommand.Execute

 FindUser = GetObject(objRecordSet.Fields("adspath"))
 WScript.Echo "You E-Mail Address is: " & objUser.EmailAddress
 objConnection.Close    
End Function

Unfortunatley VBScript throws an error on the line where I make an assignment to the function’s return value.

FindUser = GetObject(objRecordSet.Fields("adspath"))

The Error looks like “wrong number of arguments or invalid property assignment”.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:00:12+00:00Added an answer on May 14, 2026 at 5:00 am

    Looks like you need:

    Set FindUser = GetObject(objRecordSet.Fields("adspath"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My final code looks like this: <a href=/galleries/hairtinsels/hairtinsel/hairtinsels.jpg rel=shadowbox[gallery] title=Hair Tinsels, 24 Colour Choices,
After loosing much sleep I still cannot figure this out: The code below (its
I freaking loosing my mind on this: I have this code: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name =
I'm losing some hair over Google's AJAX API currently. What I do is turning
Looking to do a bit of refactoring... Using NHibernate I have this query currently
I'm loosing my hair trying to figure out why net.sf.json.JSONObject add extra backslash where
If I use durable subscription, can I restart my client and resubscribe without loosing
Here is how setup looks like: ApplicationServer - GlassFish Database Server - Oracle 10g2
I'm losing some hair over this. I found several online threads with a similar
Good day sirs, because it looks like mine isn't going to be that good.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.