Windows 从VBScript中的函数返回引用
我在用VBScript脱发。我如何才能将引用作为函数的返回值传递 当前我的代码如下所示:Windows 从VBScript中的函数返回引用,windows,scripting,vbscript,Windows,Scripting,Vbscript,我在用VBScript脱发。我如何才能将引用作为函数的返回值传递 当前我的代码如下所示: 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.Conne
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
该错误看起来像参数数目错误或属性分配无效
我做错了什么?设置FindUser=
设置FindUser=
看起来您需要:
Set FindUser = GetObject(objRecordSet.Fields("adspath"))
看起来您需要:
Set FindUser = GetObject(objRecordSet.Fields("adspath"))