我正在使用 windows server 2008 R2 64 位和 IIS 7.5 并托管一个经典的 asp(32 位)网站并在 COM 服务器(也有 windows server 2008 R2 64 位)上调用 COM 组件。但收到错误“权限被拒绝”,错误代码为 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
谢谢, 瓦巴夫