VBScript运行时时错误“800a000d” [英] VBScript Runtime Error '800a000d'
问题描述
在我们的业务中,我们使用安全向导来控制和管理活动目录安全性的同时也具备所做的更改的审计线索。这是一个SQL数据库与ASP的前端,其中也有沟通,我们的Active Directory中。
是谁写的向导的人,自从我们的网站为公司的另一部分工作,我试图得到的东西的工作是坏了。
该系统的一个简单概述是:
- 用户提交到authoriser的请求,谁再接受或拒绝有问题的用户的请求被授予访问该文件夹/资源
- 如果在authoriser接受该请求,然后他打开了向导,并授予它 - 电子邮件发送给它为我们授予访问权限
- 我们已经授予的访问权限后,我们就打勾在向导中哪些电子邮件的盒子既用户和authoriser通知他们授权访问的
本系统的部分提供了文件夹/资源authorisers做了检查哪些用户可以访问他们的授权文件夹。这已经运作良好,直到我们已经改变了我们的文件夹的命名标准:
老命名标准 - BusinessFolderPurpose如BakerHumanResources
新的命名标准 - 企业 - 网站 - 服务器所在地 - 文件夹目的如贝克 - 英格兰 - Server123 - 人力资源
当用户试图使用这说明他们谁有权访问他们现在reciecing以下错误消息向导的一部分:
Microsoft VBScript运行时错误800a000d
类型不匹配:UBOUND
/Saw/list_grp_mem.asp 18行
块引用>我怀疑的问题是,新的文件夹命名约定中有hypens这是造成一个问题 - 但unforuntaltey我不能修复它depsite多次试图寻找它和很多周围的Googling
。18号线是:
iRowNumber = UBOUND(GroupArray,2)
满code为list_grp_mem.asp网页是:
<! - #include文件=数据库/ database.asp - >
<%WriteHTMLHeader(安全访问向导)
VarUser = Request.ServerVariables(AUTH_USER)
VarUser =(右(VarUser,(LEN(VarUser)-instr(VarUser,\\))))
StrGroupName =的Request.Form(SecurityGroup)------------------------------------------------- ----------------------------
生成组成员清单集团通过StrGroupName传递
------------------------------------------------- ----------------------------
如果不为IsEmpty(StrGroupName)然后 GroupArray = QueryADGroup(distinguishedName来,strGroupName)
如果为IsEmpty(GroupArray)然后
回复于无小组发现
其他
iRowNumber = UBOUND(GroupArray,2)
如果iRowNumber = 0则
GroupDN = GroupArray(0,0) 设置RsGroupName =的Server.CreateObject(ADODB.RecordSet)
STRSQL =SELECT Company.Description AS Comp_Desc,SecurityGroups.Description AS Sec_Desc,SecurityGroups.SecurityGroup&放大器; _
从公司INNER JOIN SecurityGroups ON Company.Company = SecurityGroups.Company&放大器; _
WHERE SecurityGroups.SecurityGroup ='&放大器; StrGroupName&安培; '
RsGroupName.open STRSQL,objConn
这样做虽然不RsGroupName.EOF
的Response.Write< H2基团成员身份:&放大器; RsGroupName(Comp_Desc)及 - 与& RsGroupName(Sec_Desc)及&所述; / H2>中&安培; vbcrlf
RsGroupName.MoveNext
循环
RsGroupName.Close
其他
回复于无小组发现
万一
万一 arrGrpMem = QueryADUsers(GroupsMembersGroupDN)
如果为IsEmpty(arrGrpMem)然后
的Response.Write错误组未找到
其他
iRowNumber = UBOUND(arrGrpMem,2)
如果iRowNumber = 0则
回复于集团目前没有任何成员
其他
的Response.Write<表类=&放大器;字符(34)及REQ与&字符(34)及>中&安培; vbcrlf
回复于&所述; TR>中&安培; vbcrlf
的Response.Write< TD类=&放大器;字符(34)及ReqHead与&字符(34)及>名称和LT; / TD>中&安培; vbcrlf
的Response.Write< TD类=&放大器;字符(34)及ReqHead与&字符(34)及>电子邮件< / TD>中&安培; vbcrlf
回复于&下; / TR>中&安培; vbcrlf
对于iCounter = 0到iRowNumber
如果不ISNULL(arrGrpMem(3 iCounter))然后
如果INSTR(arrGrpMem(3 iCounter),ZZ)= 0,那么
回复于&所述; TR>中&安培; vbcrlf
的Response.Write< TD类=&放大器;字符(34)及ReqLeft与&字符(34)及>中和放大器; arrGrpMem(3,iCounter)及与& arrGrpMem(4,iCounter)及&所述; / TD>中&安培; vbcrlf
的Response.Write< TD类=&放大器;字符(34)及ReqLeft与&字符(34)及>(与& arrGrpMem(6,iCounter)及)&下; / TD>中&安培; vbcrlf
回复于&下; / TR>中&安培; vbcrlf
万一
万一
下一个
的Response.Write< /表> &安培; vbcrlf
万一
万一
万一------------------------------------------------- ----------------------------
生成选项框团体对于用户是指定Authoriser
------------------------------------------------- ----------------------------
如果为IsEmpty(StrGroupName)然后
的Response.Write< H2基团成员报告< / H2>中&安培; vbcrlf
的Response.Write< P>< B>请选择您需要℃的会员报告的区域; / B>中&安培; vbcrlf
的Response.Write<形式的行动=&放大器;字符(34)及list_grp_mem.asp与&字符(34)及方法=&放大器;字符(34)及后&放大器;字符(34)及>中&安培; vbcrlf
的Response.Write<选择名称=&放大器;字符(34)及SecurityGroup与&字符(34)及>中
设置RsAuthGroups =的Server.CreateObject(ADODB.RecordSet)
STRSQL =SELECT DISTINCT SecurityGroups.SecurityGroup,SecurityGroups.Description AS Sec_Desc,Authorisation.NTAccount,Company.Type,Company.Description AS Comp_Desc&放大器; _
从公司INNER JOIN SecurityGroups ON Company.Company = SecurityGroups.Company INNER JOIN&放大器; _
授权ON SecurityGroups.SecurityGroup = dbo.Authorisation.SecurityGroup&放大器; _
WHERE(Company.Type ='1'AND Authorisation.NTAccount ='&放大器; VarUser&安培;')AND SecurityGroups.Active = 1
RsAuthGroups.open STRSQL,objConn
这样做虽然没有RsAuthGroups.EOF遍历组和产生形式的选择。
的Response.Write<期权价值=&放大器;字符(34)及替换(RsAuthGroups(SecurityGroup),,)及字符(34)及>中和放大器; RsAuthGroups(Comp_Desc)及 - 与& RsAuthGroups(Sec_Desc)及< /选项>&放大器; vbcrlf
RsAuthGroups.MoveNext
循环
RsAuthGroups.Close
的Response.Write< /选择>中&安培; vbcrlf
的Response.Write< BR />< BR />在你选择一个区域,请preSS< B>中&安培;字符(34)及下一步&放大器;字符(34)及&所述; / B个;&下; / P>中&安培; vbcrlf
的Response.Write<输入类型=&放大器;字符(34)及提交&放大器;字符(34)及VALUE =&放大器;字符(34)及下一步&放大器;字符(34)及/>中&安培; vbcrlf
回复于&下; / P>中&安培; vbcrlf
的Response.Write< /形式为GT; &安培; vbcrlf
万一------------------------------------------------- ----------------------------
显示链接返回首页
------------------------------------------------- ----------------------------
的Response.Write<人力资源类=&放大器;字符(34)及灰色和放大器;字符(34)及/>中&安培; vbcrlf
回复于&所述; P>中&安培; vbcrlf
回复于&下; A HREF =&放大器;字符(34)及Default.asp的&放大器;字符(34)及>返回安全访问向导< / A>< / BR>中&安培; vbcrlf
回复于&下; / P>中&安培; vbcrlf%GT;<%WriteHTMLFooter()%GT;编辑:这是一个复制和放大器;在QueryADGroup从Database.asp粘贴:的
<$c$c>'-----------------------------------------------------------------------------
QueryADGroup返回一个数组
------------------------------------------------- ----------------------------功能QueryADGroup(StrQryType,StrQryValue)
设置oRootDSE = GetObject的(LDAP:// RootDSE的)
sDomainADsPath =LDAP://&放大器; oRootDSE.Get(defaultNamingContext)
设置oRootDSE =什么
设置奥孔=的Server.CreateObject(ADODB.Connection)
的suser =删除
spassword开头=删除
oCon.Provider =ADsDSOObject
oCon.OpenADProvider的suser,spassword开头
设置oCmd =的Server.CreateObject(ADODB.Command)
设置oCmd.ActiveConnection =奥孔
sProperties =的distinguishedName
选择的情况下StrQryType
案的distinguishedName,CN
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=组)(SAM帐户名=与&amp; StrQryValue&放大器;)); &安培; sProperties'和; 子树
其他情况下,
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=组)(SAM帐户名=与&amp; StrQryValue&放大器;)); &安培; sProperties'和; 子树
最终选择
oCmd.Properties(大小)= 100
设置oRecordSet = oCmd.Execute
如果oRecordSet.BOF = TRUE然后
QueryADGroup = NULL
其他
QueryADGroup = oRecordSet.GetRows()
万一
oRecordSet.Close
oCon.Close
结束功能
有没有人能帮助/帮助我试图找出什么问题吗?
我会非常感谢任何指针!
进一步误差
没有发现集团
提供程序错误'8007203e
搜索筛选器无法识别。
/Saw/database/database.asp,行173
块引用>实施@ Lankymart的建议后,
173行是:
如果oRecordSet.BOF = TRUE,则
这是database.asp的它正在试图获得用户的部分从AD:
------------------------ -------------------------------------------------- ---
让用户从查询
返回二维数组与用户的信息来源以以下格式
0,X - 用户主体名称
1,X - SAMAccount名称(NTACCOUNT)
2,X - 显示名称
3,X - 给定的名称
'4,X - 姓
5,X - 说明(出于某种原因,它返回一个数组)
6,X - 电子邮件
7,X - SID(二进制)
9,X - 加以区分名称
10,X - 职位
11,X - 公司
------------------------------------------------- ----------------------------
功能QueryADUsers(StrQryType,StrQryValue) 设置oRootDSE = GetObject的(LDAP:// RootDSE的)
sDomainADsPath =LDAP://&放大器; oRootDSE.Get(defaultNamingContext)
设置oRootDSE =什么
设置奥孔=的Server.CreateObject(ADODB.Connection)
的suser =删除
spassword开头=删除
oCon.Provider =ADsDSOObject
oCon.OpenADProvider的suser,spassword开头
设置oCmd =的Server.CreateObject(ADODB.Command)
设置oCmd.ActiveConnection =奥孔
sProperties = \"userPrincipalName,SAMAccountname,name,givenName,sn,description,mail,objectsid,memberof,distinguishedName,title,company\"
选择的情况下StrQryType
案姓
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=用户)(SN =与&amp; StrQryValue&放大器;*)); &安培; sProperties'和; 子树
案SAM帐户名
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=用户)(SAM帐户名=与&amp; StrQryValue&放大器;)); &安培; sProperties'和; 子树
案GroupsMembers
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=用户)(的memberOf =与&amp; StrQryValue&放大器;)); &安培; sProperties'和; 子树
其他情况下,
oCmd.CommandText =下; &安培; sDomainADsPath&安培; 取代;(及(objectCategory属性=用户)(的UserPrincipalName =与&amp; StrQryValue&放大器;*)); &安培; sProperties'和; 子树
最终选择 oCmd.Properties(大小)= 100
设置oRecordSet = oCmd.Execute
如果oRecordSet.BOF = TRUE然后
QueryADUser = NULL
其他
oRecordset.SortSN,给定名称
QueryADUsers = oRecordSet.GetRows()
万一
oRecordSet.Close
oCon.Close
结束功能
解决方案什么问题?
问题是使用
的IsEmpty()
当您返回验证检查GroupArray
从QueryADGroup()
功能。这是因为
的IsEmpty()
用于返回真
如果其中的两个条件得到满足;
- 变量尚未初始化的(没有价值分配)的
- 变量已明确设置为
vbEmpty
。任何东西都不会返回
假
甚至分配到空
变量。
从片段 MSDN - IsEmpty函数
的IsEmpty 返回真如果变量未初始化或显式设置为空的;否则,返回的假。 假如果前pression包含多个变量总是返回。
下面的示例使用的的IsEmpty 函数来确定一个变量是否已初始化:的
暗淡MyVar的,MyCheck
MyCheck =的IsEmpty(MyVar的)'返回True。
为MyVar = NULL'null分配。
MyCheck =的IsEmpty(MyVar的)'返回False。
为MyVar =空指定空。
MyCheck =的IsEmpty(MyVar的)'返回True。
块引用>是什么原因导致了
类型不匹配
错误?通过设置
QueryADGroup = NULL
在QueryADGroup()
函数你绕过为IsEmpty()
检查,因为它总是会假
。这意味着,当行iRowNumber = UBOUND(GroupArray,2)
试图检查
空
的上限它失败,出现错误
Microsoft VBScript运行时错误800a000d
类型不匹配:UBOUND
/Saw/list_grp_mem.asp 18行
块引用>因为它需要一个
阵列
不是空
。建议的解决方法
相反,你可以做两件事情。
修改
QueryADGroup = NULL
到QueryADGroup =空缺
这样的IsEmpty( )
将返回真
现在空缺
已明确设置。QueryADGroup =空
使用
IsArray的()
而不是中的IsEmpty()
来检查一个有效的返回值。由于结果总是有望成为一个阵列
这似乎是更好的选择,因为它会赶上无效的阵列任何返回值。如果不IsArray的(GroupArray)然后
相关链接
In our business, we use a security wizard to control and administer active directory security and also to have an audit trail of changes made. This is a SQL database with an ASP front end, which also has communication to our Active Directory.
The person who wrote the wizard has since our site to work for another part of the company and I am attempting to get something working which is broken.
A simple overview of the system is:
- User submits a request to an authoriser, who then accepts or rejects the request for the user in question to be granted access to the folder/resource
- If the authoriser accepts the request, he then opens up the wizard and authorises it - an email is sent to IT for us to grant the access
- After we have granted the access we then tick a box in the wizard which emails both the user and the authoriser informing them of the granted access
Part of this system gives the authorisers of the folders/resources to do a check of which users have access to their authorising folders. This has been working well, until we have changed the naming standard of our folders:
Old naming standard - "BusinessFolderPurpose" e.g. "BakerHumanResources" New naming standard - "Business - Site - Server Location - Folder Purpose" e.g. "Baker - England - Server123 - Human Resources"
When the users are attempting to use the part of the wizard which shows them who has access they are now reciecing the following error message:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'ubound'
/Saw/list_grp_mem.asp, line 18
I suspect the issue is that the new folder naming convention has hypens in it which is causing a problem - but unforuntaltey I am not able to fix it depsite numerous attempts looking at it and much Googling around.
Line 18 is:
iRowNumber = ubound(GroupArray,2)
The full code for the list_grp_mem.asp page is:
<!--#include file = "database/database.asp"--> <% WriteHTMLHeader("Security Access Wizard") VarUser = Request.ServerVariables("AUTH_USER") VarUser =(Right(VarUser,(len(VarUser)-instr(VarUser,"\")))) StrGroupName = Request.Form("SecurityGroup") '----------------------------------------------------------------------------- 'Generate Group Membership Listing From Group Passed via StrGroupName '----------------------------------------------------------------------------- If Not IsEmpty(StrGroupName) Then GroupArray = QueryADGroup("distinguishedName",strGroupName) If IsEmpty(GroupArray) Then Response.Write "No Group Found" Else iRowNumber = ubound(GroupArray,2) if iRowNumber = 0 Then GroupDN = GroupArray(0,0) Set RsGroupName = Server.CreateObject("ADODB.RecordSet") StrSql = "SELECT Company.Description AS Comp_Desc, SecurityGroups.Description AS Sec_Desc, SecurityGroups.SecurityGroup " & _ "FROM Company INNER JOIN SecurityGroups ON Company.Company = SecurityGroups.Company " & _ "WHERE SecurityGroups.SecurityGroup = '" & StrGroupName & "'" RsGroupName.open StrSql,objConn Do While NOT RsGroupName.EOF Response.Write "<h2>Group Membership For: " & RsGroupName("Comp_Desc") & " - " & RsGroupName("Sec_Desc") & "</h2>" & vbcrlf RsGroupName.MoveNext Loop RsGroupName.Close Else Response.Write "No Group Found" End If End If arrGrpMem = QueryADUsers("GroupsMembers",GroupDN) If IsEmpty(arrGrpMem) Then Response.Write "Error Group Not Found" Else iRowNumber = ubound(arrGrpMem,2) If iRowNumber = 0 Then Response.Write "Group Currently Has No Members" Else Response.Write "<table class=" & chr(34) & "Req" & Chr(34) & ">" & vbcrlf Response.Write " <tr>" & vbcrlf Response.Write " <td class=" & chr(34) & "ReqHead" & Chr(34) & "> Name </td>" & vbcrlf Response.Write " <td class=" & chr(34) & "ReqHead" & Chr(34) & "> E-Mail </td>" & vbcrlf Response.Write " </tr>" & vbcrlf For iCounter = 0 To iRowNumber If Not IsNull(arrGrpMem(3,iCounter)) Then If Instr(arrGrpMem(3,iCounter),"ZZ") = 0 Then Response.Write " <tr>" & vbcrlf Response.Write " <td class=" & chr(34) & "ReqLeft" & Chr(34) & "> " & arrGrpMem(3,iCounter) & " " & arrGrpMem(4,iCounter) & " </td>" & vbcrlf Response.Write " <td class=" & chr(34) & "ReqLeft" & Chr(34) & ">(" & arrGrpMem(6,iCounter) & ") </td>" & vbcrlf Response.Write " </tr>" & vbcrlf End If End If Next Response.Write "</table>" & vbcrlf End If End If End IF '----------------------------------------------------------------------------- 'Generate Option Box For Groups For Which User Is A Designated Authoriser '----------------------------------------------------------------------------- If IsEmpty(StrGroupName) Then Response.Write "<h2> Group Membership Report</h2>" & vbcrlf Response.Write "<p><b> Please select the area you require a membership report for</b>" & vbcrlf Response.Write "<form action=" & chr(34) & "list_grp_mem.asp" & chr(34) & " method=" & chr(34) & "post" & chr(34) & ">" & vbcrlf Response.Write "<select name=" & chr(34) & "SecurityGroup" & Chr(34) & ">" Set RsAuthGroups = Server.CreateObject("ADODB.RecordSet") StrSql = "SELECT DISTINCT SecurityGroups.SecurityGroup, SecurityGroups.Description AS Sec_Desc ,Authorisation.NTAccount, Company.Type, Company.Description AS Comp_Desc " & _ "FROM Company INNER JOIN SecurityGroups ON Company.Company = SecurityGroups.Company INNER JOIN " & _ "Authorisation ON SecurityGroups.SecurityGroup = dbo.Authorisation.SecurityGroup " & _ "WHERE (Company.Type ='1' AND Authorisation.NTAccount = '" & VarUser & "') AND SecurityGroups.Active = 1" RsAuthGroups.open StrSql,objConn Do While NOT RsAuthGroups.EOF 'Loop through groups and generate form options. Response.Write " <option value=" & chr(34) & Replace(RsAuthGroups("SecurityGroup")," ","") & chr(34) & "> " & RsAuthGroups("Comp_Desc") & " - " & RsAuthGroups("Sec_Desc") & " </option>"& vbcrlf RsAuthGroups.MoveNext Loop RsAuthGroups.Close Response.Write "</select>" & vbcrlf Response.Write "<br/><br/>Once you have selected an area please press <b>" & chr(34) & "Next" & chr(34) & "</b></p>" & vbcrlf Response.Write "<input type =" & chr(34) & "submit" & chr(34) & "value =" & chr(34) & " Next " & chr(34) & "/>" & vbcrlf Response.Write "</p>" & vbcrlf Response.Write "</form>" & vbcrlf End If '----------------------------------------------------------------------------- ' Display Link Back To Homepage '----------------------------------------------------------------------------- Response.Write "<hr class=" & Chr(34) & "grey" & chr(34) & "/>" & vbcrlf Response.Write "<p>" & vbcrlf Response.Write " <a href=" & chr(34) & "default.asp" & chr(34) & "> Back To Security Access Wizard</a></br>" & vbcrlf Response.Write "</p>" & vbcrlf %> <%WriteHTMLFooter()%>
EDIT: Here is a copy & paste of the QueryADGroup from Database.asp:
'----------------------------------------------------------------------------- ' QueryADGroup Returns An Array '----------------------------------------------------------------------------- Function QueryADGroup(StrQryType,StrQryValue) Set oRootDSE = GetObject("LDAP://RootDSE") sDomainADsPath = "LDAP://" & oRootDSE.Get("defaultNamingContext") Set oRootDSE = Nothing Set oCon = Server.CreateObject("ADODB.Connection") sUser = "removed" sPassword = "removed" oCon.Provider = "ADsDSOObject" oCon.Open "ADProvider", sUser, sPassword Set oCmd = Server.CreateObject("ADODB.Command") Set oCmd.ActiveConnection = oCon sProperties = "distinguishedName" select case StrQryType case "distinguishedName,cn" oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=group)(SAMAccountName=" & StrQryValue & "));" & sProperties '& ";subtree" case else oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=group)(SAMAccountName=" & StrQryValue & "));" & sProperties '& ";subtree" end select oCmd.Properties("Page Size") = 100 Set oRecordSet = oCmd.Execute If oRecordSet.BOF = True Then QueryADGroup = Null Else QueryADGroup = oRecordSet.GetRows() End If oRecordSet.Close oCon.Close End Function
Is anyone able to help/assist me try and figure out what the issue is please?
I'd be most grateful for any pointers!
Further error
No Group Found
Provider error '8007203e'
The search filter cannot be recognized.
/Saw/database/database.asp, line 173
After implementing @Lankymart's suggestion
Line 173 is:
If oRecordSet.BOF = True Then
This is the section of database.asp where it is trying to get the users from AD:
'----------------------------------------------------------------------------- ' Get Users From Query ' ' Returns 2D Array with user infomation in following format ' 0,x - User Principle Name ' 1,x - SAMAccount Name(NTAccount) ' 2,x - Display Name ' 3,x - Given Name ' 4,x - Surname ' 5,x - Description (For Some Reason Its returned as an array) ' 6,x - Email ' 7,x - SID (Binary) ' 9,x - Distinguised Name ' 10,x - Job Title ' 11,x - Company '-----------------------------------------------------------------------------' Function QueryADUsers(StrQryType,StrQryValue) Set oRootDSE = GetObject("LDAP://RootDSE") sDomainADsPath = "LDAP://" & oRootDSE.Get("defaultNamingContext") Set oRootDSE = Nothing Set oCon = Server.CreateObject("ADODB.Connection") sUser = "removed" sPassword = "removed" oCon.Provider = "ADsDSOObject" oCon.Open "ADProvider", sUser, sPassword Set oCmd = Server.CreateObject("ADODB.Command") Set oCmd.ActiveConnection = oCon sProperties = "userPrincipalName,SAMAccountname,name,givenName,sn,description,mail,objectsid,memberof,distinguishedName,title,company" select case StrQryType case "Surname" oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=user)(sn=" & StrQryValue & "*));" & sProperties '& ";subtree" case "SAMAccountName" oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=user)(SAMAccountName=" & StrQryValue & "));" & sProperties '& ";subtree" case "GroupsMembers" oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=user)(MemberOf= " & StrQryValue & " ));" & sProperties '& ";subtree" case else oCmd.CommandText = "<" & sDomainADsPath & ">;(&(objectCategory=user)(userPrincipalName=" & StrQryValue & "*));" & sProperties '& ";subtree" end select oCmd.Properties("Page Size") = 100 Set oRecordSet = oCmd.Execute If oRecordSet.BOF = True Then QueryADUser = Null Else 'oRecordset.Sort "sn,givenName" QueryADUsers = oRecordSet.GetRows() End If oRecordSet.Close oCon.Close End Function
解决方案What's the Problem?
The problem is the use of
IsEmpty()
as the validation check when you returnGroupArray
from theQueryADGroup()
function.This is because
IsEmpty()
is designed to returnTrue
if either of two conditions are met;
- Variable has not been initialised (no value assigned).
- Variable has been explicitly set to
vbEmpty
.anything else will return
False
even variables assigned toNull
.Snippet from MSDN - IsEmpty Function
IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False. False is always returned if expression contains more than one variable. The following example uses the IsEmpty function to determine whether a variable has been initialized:
Dim MyVar, MyCheck MyCheck = IsEmpty(MyVar) ' Returns True. MyVar = Null ' Assign Null. MyCheck = IsEmpty(MyVar) ' Returns False. MyVar = Empty ' Assign Empty. MyCheck = IsEmpty(MyVar) ' Returns True.
What Causes the
Type mismatch
Error?By setting
QueryADGroup = Null
in theQueryADGroup()
function you are bypassing theIsEmpty()
check because it will always beFalse
. That means when the lineiRowNumber = ubound(GroupArray,2)
attempts to check the upper bounds of
Null
it fails with the errorMicrosoft VBScript runtime error '800a000d'
Type mismatch: 'ubound'
/Saw/list_grp_mem.asp, line 18
because it expects an
Array
not aNull
.Suggested Solutions
Instead you can do two things.
Change
QueryADGroup = Null
toQueryADGroup = Empty
that wayIsEmpty()
will returnTrue
now thatEmpty
has been explicitly set.QueryADGroup = Empty
Use
IsArray()
instead ofIsEmpty()
to check for a valid return value. As the result is always expected to be anArray
this seems the better option, as it will catch any return values that are not valid Arrays.If Not IsArray(GroupArray) Then
Useful Links
这篇关于VBScript运行时时错误“800a000d”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!