尝试使用Scripting.Dictionary时,权限被拒绝错误

时间:2012-06-05 06:28:17

标签: com asp-classic vb6 iis-7.5 windows-server-2008-r2

我正在使用Windows Server 2008 R2 64位和IIS 7.5并托管经典的asp(32位)网站并调用COM服务器上的COM组件(它也有Windows服务器2008 R2 64位)。但是获得错误“Permission denied”和错误代码是800A0046。

Set oDictAOGroup = CreateObject("Scripting.Dictionary")
oDictAOGroup.Add "1000", "5"
oUser.fn_Update_AO_Groups(oDictAOGroup)

asp网站服务器使用DCOM与COM服务器通信。在asp网站上,服务器代理是由COM服务器类创建的。

我创建了一个测试函数并将值传递给该函数,然后代码完全正常。

oUser.fn_Update_AO_Groups_Test1("1000", "21")

但是当尝试传递Scipting.Dictionary对象时,会引发权限被拒绝错误。 我已经搜索过很多内容了,但这一切都是徒劳无益的。

功能代码是

Public Function fn_Update_AO_Groups(vntAODict As Variant)

On Error GoTo ErrorHandler

Dim oADOConnect As AMLCONNECT_V2.clsConnect
Dim oADOConn        As ADODB.Connection
Dim oADOCmd         As ADODB.Command
Dim vntKey          As Variant

    If Not objContext Is Nothing Then
        Set oADOConnect = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
        Set oADOCmd = objContext.CreateInstance("ADODB.Command")
    Else
        Set oADOConnect = New clsConnect
        Set oADOCmd = New ADODB.Command
    End If

    If IsObject(vntAODict) Then
        If oADOConnect.OpenADOConnection(oADOConn) Then
            With oADOCmd
                .CommandText = "Sp_Upd_AOGroups"
                .CommandType = adCmdStoredProc
                .Parameters.Append .CreateParameter("AO_ID", adInteger, adParamInput)
                .Parameters.Append .CreateParameter("Email_Group_ID", adInteger, adParamInput)
                Set .ActiveConnection = oADOConn
            End With
            'Execute stored procedure for each item in the dictionary
            For Each vntKey In vntAODict.Keys
                oADOCmd.Parameters("AO_ID").Value = vntKey
                oADOCmd.Parameters("Email_Group_ID").Value = vntAODict(vntKey)
                oADOCmd.Execute
            Next
        End If
    End If

TidyUp:

    Set oADOConn = Nothing
    Set oADOCmd = Nothing
    Set oADOConnect = Nothing

Exit Function

ErrorHandler:
    Dim ErrHandler As AMLCONNECT_V2.clsConnect

    If Not objContext Is Nothing Then
        Set ErrHandler = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
    Else
        Set ErrHandler = New AMLCONNECT_V2.clsConnect
    End If

    m_sErrorMessage = "Error Number: " + CStr(Err.Number) + "<BR>" + "Description: " + ErrHandler.LogError(Err.Number, Err.Description, "MODULE: AMLADMIN_V2.clsUsers", "FUNCTION:fn_Update_AO_Groups", errError, errVB, errDatabase, "")

    If Not ErrHandler Is Nothing Then Set ErrHandler = Nothing

    GoTo TidyUp:

End Function

任何人都可以为此提出补救措施吗?

函数接受字符串的代码

Public Function fn_Update_AO_Groups_Test1(strKey As String, strValue As String)

On Error GoTo ErrorHandler

Dim oADOConnect As AMLCONNECT_V2.clsConnect
Dim oADOConn        As ADODB.Connection
Dim oADOCmd         As ADODB.Command
Dim vntKey          As Variant

Dim ErrHandlerTest As AMLCONNECT_V2.clsConnect

    If Not objContext Is Nothing Then
        Set oADOConnect = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
        Set oADOCmd = objContext.CreateInstance("ADODB.Command")

    Else
        Set oADOConnect = New clsConnect
        Set oADOCmd = New ADODB.Command

    End If

            If oADOConnect.OpenADOConnection(oADOConn) Then
                With oADOCmd
                    .CommandText = "Sp_Upd_AOGroups"
                    .CommandType = adCmdStoredProc
                    .Parameters.Append .CreateParameter("AO_ID", adInteger, adParamInput)
                    .Parameters.Append .CreateParameter("Email_Group_ID", adInteger, adParamInput)
                    Set .ActiveConnection = oADOConn
                End With
                'Execute stored procedure for each item in the dictionary
                    oADOCmd.Parameters("AO_ID").Value = strKey
                    oADOCmd.Parameters("Email_Group_ID").Value = strValue
                    oADOCmd.Execute
            End If
TidyUp:

    Set oADOConn = Nothing
    Set oADOCmd = Nothing
    Set oADOConnect = Nothing

Exit Function

ErrorHandler:
    Dim ErrHandler As AMLCONNECT_V2.clsConnect

    If Not objContext Is Nothing Then
        Set ErrHandler = objContext.CreateInstance("AMLCONNECT_V2.clsConnect")
    Else
        Set ErrHandler = New AMLCONNECT_V2.clsConnect
    End If

    m_sErrorMessage = "Error Number: " + CStr(Err.Number) + "<BR>" + "Description: " + ErrHandler.LogError(Err.Number, Err.Description, "MODULE: AMLADMIN_V2.clsUsers", "FUNCTION:fn_Update_AO_Groups", errError, errVB, errDatabase, "")

    If Not ErrHandler Is Nothing Then Set ErrHandler = Nothing

    GoTo TidyUp:

End Function

谢谢, Vaibhav的

3 个答案:

答案 0 :(得分:0)

评论太长了,所以虽然这不是完整答案,但它可能会让你朝着正确的方向发展。

首先,我注意到字段类型是整数,而字典键和值是字符串。因此,首先尝试通过将函数中的代码更改为:

来转换它们
oADOCmd.Parameters("AO_ID").Value = CLng(vntKey)
oADOCmd.Parameters("Email_Group_ID").Value = CLng(vntAODict(vntKey))

如果仍然是同样的错误,我需要知道当你明确地将两个参数传递给函数而不是字典时,完全相同的代码是否正常工作?

我想到的另一件事是,您的错误处理可能出现问题,请尝试将其删除以便进行调试,并查看是否收到更有意义的错误消息。

答案 1 :(得分:0)

使用Call oUser.fn_Update_AO_Groups(oDictAOGroup)oUser.fn_Update_AO_Groups oDictAOGroup不加括号。

答案 2 :(得分:0)

请尝试使用这些签名:

Public Function fn_Update_AO_Groups(ByVal vntAODict As Variant) 

Public Function fn_Update_AO_Groups(ByVal vntAODict As Scripting.Dictionary)

如果允许默认ByRef占优势,则需要更多的编组代码。同时提供期望的explict类型也为编组代码提供了更多选项。这些更改可能足以允许您期望的操作。

如果失败了,我会重新考虑这种方法,我更喜欢将XML字符串传递到SP中。这提供了最大的灵活性,允许对SQL和ASP进行代码更改以实现新的需求,而无需重新编译和部署新的二进制文件。