ASP.NET中的CoInitializeSecurity [英] CoInitializeSecurity in ASP.NET
问题描述
您好,
i尝试访问本地虚拟服务器对象。
我有一个带有按钮和文本框的aspx页面,这是代码:
公共类WebForm1:System.Web.UI.Page
{
protected System.Web.UI.WebControls .Button btnFillBox;
protected System.Web.UI.WebControls.TextBox txtHost;
protected System.Web.UI.WebControls.Label Label1;
public enum RpcAuthnLevel
{
默认= 0,
无= 1,
连接= 2,
电话= 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
}
公共枚举RpcImpLevel
{
默认值= 0,
Anonymous = 1,
Identify = 2,
Impersonate = 3,
Delegate = 4
}
公共枚举EoAuthnCap
{
无= 0x00,
Mutua lAuth = 0x01,
StaticCloaking = 0x20,
DynamicCloaking = 0x40,
AnyAuthority = 0x80,
MakeFullSIC = 0x100,
默认= 0x800,
SecureRefs = 0x02,
AccessControl = 0x04,
AppID = 0x08,
动态= 0x10,
RequireFullSIC = 0x200,
AutoImpersonate = 0x400,
NoCustomMarshal = 0x2000,
DisableAAA = 0x1000
}
[DllImport(" ole32.dll")]
public static extern int CoInitializeSecurity(IntPtr pVoid,int
cAuthSvc,IntPtr asAuthSvc,IntPtr pReserved1,RpcAuthnLevel level,
RpcImpLevel impers,IntPtr pAuthList,int dwCapabilities,IntPtr
pReserved3);
#region Web表单设计器生成的代码
覆盖protected void OnInit(EventArgs e)
{
//
// CODEGEN:ASP.NET Web表格需要此调用
Designer。
//
Initiali zeComponent();
base.OnInit(e);
}
///< summary>
/// Designer支持所需的方法 - 不要使用代码编辑器修改
///此方法的内容。
///< ; / summary>
private void InitializeComponent()
{
this.btnFillBox.Click + = new System.EventHandler
(this.btnFillBox_Click);
this.Load + = new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender,System.EventArgs e)
{
this.txtHost.Text ="";
CoInitializeSecurity(IntPtr.Zero,-1,IntPtr.Zero,
IntPtr.Zero ,RpcAuthnLevel.PktIntegrity,
RpcImpLevel.Identify,IntPtr.Zero,0x40,IntPtr.Zero);
VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
我总是得到一个拒绝访问 on vs = new VMVirtualServerClass();
我尝试过不同的CoInitializeSecurity组合,但没有
成功。
任何人都有通过
ASP.NET访问虚拟服务器(COM)的经验?或者VS有另一个可用的界面吗?
非常感谢
Clas
-
隧道尽头的灯,
由于成本高而被关闭。
Hello,
i try to get access to a local virtual server object.
I have a aspx page with a button and textbox, this is the code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnFillBox;
protected System.Web.UI.WebControls.TextBox txtHost;
protected System.Web.UI.WebControls.Label Label1;
public enum RpcAuthnLevel
{
Default = 0,
None = 1,
Connect = 2,
Call = 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
}
public enum RpcImpLevel
{
Default = 0,
Anonymous = 1,
Identify = 2,
Impersonate = 3,
Delegate = 4
}
public enum EoAuthnCap
{
None = 0x00,
MutualAuth = 0x01,
StaticCloaking= 0x20,
DynamicCloaking= 0x40,
AnyAuthority= 0x80,
MakeFullSIC= 0x100,
Default= 0x800,
SecureRefs= 0x02,
AccessControl= 0x04,
AppID= 0x08,
Dynamic= 0x10,
RequireFullSIC= 0x200,
AutoImpersonate= 0x400,
NoCustomMarshal= 0x2000,
DisableAAA= 0x1000
}
[DllImport("ole32.dll")]
public static extern int CoInitializeSecurity( IntPtr pVoid, int
cAuthSvc,IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel level,
RpcImpLevel impers,IntPtr pAuthList, int dwCapabilities, IntPtr
pReserved3 );
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnFillBox.Click += new System.EventHandler
(this.btnFillBox_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender, System.EventArgs e)
{
this.txtHost.Text = "";
CoInitializeSecurity( IntPtr.Zero, -1, IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.PktIntegrity ,
RpcImpLevel.Identify,IntPtr.Zero, 0x40, IntPtr.Zero );
VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
I always get a "Access denied" on vs = new VMVirtualServerClass();
I have tried different combinations for CoInitializeSecurity, but with no
success.
Does anybody has experience of accessing a Virtual Server (COM) through
ASP.NET ? Or is there another usable interface to VS ?
Many thanks
Clas
--
The light at the end of the tunnel,
was switch off due to high costs.
推荐答案
Clas,
你为什么要打电话给CoInitializeSecurity?由于您正在调用COM
对象,您是否将ASPCompat属性设置为true?此外,
对象是否执行需要文件或注册表访问的任何内容?
您可能需要冒充有权使用
访问虚拟服务器。
希望这会有所帮助。
-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com
" Clas Hortien" <豪***** @ hotmail.com>在消息中写道
news:ci ********** @ news1.wdf.sap-ag.de ...
Clas,
Why are you calling CoInitializeSecurity? Since you are calling a COM
object, are you setting the ASPCompat attribute to true? Also, does the
object do anything that requires file or registry access?
Chances are you will have to impersonate a user that has the rights to
access virtual server.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Clas Hortien" <ho*****@hotmail.com> wrote in message
news:ci**********@news1.wdf.sap-ag.de...
你好,
我尝试访问本地虚拟服务器对象。
我有一个带有按钮和文本框的aspx页面,这是代码:
public class WebForm1:System .Web.UI.Page
{
受保护的System.Web.UI.WebControls.Button btnFillBox;
受保护的System.Web.UI.WebControls.TextBox txtHost;
受保护的系统。 Web.UI.WebControls.Label Label1;
公共枚举RpcAuthnLevel
{
默认= 0,
无= 1,
连接= 2,
Call = 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
公共枚举RpcImpLevel
{
默认= 0,
匿名= 1,
识别= 2,
模仿= 3,
代表= 4
}
<公共枚举EoAuthnCap
{无> = 0x00,
MutualAuth = 0x01,
StaticCloaking = 0x20,
Dyna micCloaking = 0x40,
AnyAuthority = 0x80,
MakeFullSIC = 0x100,
默认值= 0x800,
SecureRefs = 0x02,
AccessControl = 0x04,
AppID = 0x08,
Dynamic = 0x10,
RequireFullSIC = 0x200,
AutoImpersonate = 0x400,
NoCustomMarshal = 0x2000,
DisableAAA = 0x1000
}
[DllImport(" ole32.dll")]
public static extern int CoInitializeSecurity(IntPtr pVoid,int
cAuthSvc,IntPtr asAuthSvc,IntPtr pReserved1,RpcAuthnLevel
level,
RpcImpLevel impers,IntPtr pAuthList,int dwCapabilities,IntPtr
pReserved3);
#region Web窗体设计器生成的代码
覆盖保护的void OnInit(EventArgs e)
{
//
// CODEGEN:ASP.NET Web Form
Designer需要此调用。
//
InitializeComponent();
base.OnInit(e);
}
///< summary>
/// Designer支持所需的方法 - 不要odify
///使用代码编辑器的方法的内容。
///< / summary>
private void InitializeComponent()
{
这。 btnFillBox.Click + = new System.EventHandler
(this.btnFillBox_Click);
this.Load + = new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender,System.EventArgs e)
{
this.txtHost.Text ="" ;;
CoInitializeSecurity(IntPtr.Zero,-1,IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.PktIntegrity,
RpcImpLevel.Identify,IntPtr.Zero,0x40,IntPtr.Zero ); VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
我总是得到一个拒绝访问 on vs = new VMVirtualServerClass();
我已经为CoInitializeSecurity尝试了不同的组合,但没有成功。
是否有人有通过访问虚拟服务器(COM)的经验
ASP.NET?或者VS有另一个可用的界面吗?
非常感谢
Clas
-
隧道尽头的灯光,
由于成本高而被关闭。
Hello,
i try to get access to a local virtual server object.
I have a aspx page with a button and textbox, this is the code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnFillBox;
protected System.Web.UI.WebControls.TextBox txtHost;
protected System.Web.UI.WebControls.Label Label1;
public enum RpcAuthnLevel
{
Default = 0,
None = 1,
Connect = 2,
Call = 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
}
public enum RpcImpLevel
{
Default = 0,
Anonymous = 1,
Identify = 2,
Impersonate = 3,
Delegate = 4
}
public enum EoAuthnCap
{
None = 0x00,
MutualAuth = 0x01,
StaticCloaking= 0x20,
DynamicCloaking= 0x40,
AnyAuthority= 0x80,
MakeFullSIC= 0x100,
Default= 0x800,
SecureRefs= 0x02,
AccessControl= 0x04,
AppID= 0x08,
Dynamic= 0x10,
RequireFullSIC= 0x200,
AutoImpersonate= 0x400,
NoCustomMarshal= 0x2000,
DisableAAA= 0x1000
}
[DllImport("ole32.dll")]
public static extern int CoInitializeSecurity( IntPtr pVoid, int
cAuthSvc,IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel
level,
RpcImpLevel impers,IntPtr pAuthList, int dwCapabilities, IntPtr
pReserved3 );
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnFillBox.Click += new System.EventHandler
(this.btnFillBox_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender, System.EventArgs e)
{
this.txtHost.Text = "";
CoInitializeSecurity( IntPtr.Zero, -1, IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.PktIntegrity ,
RpcImpLevel.Identify,IntPtr.Zero, 0x40, IntPtr.Zero );
VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
I always get a "Access denied" on vs = new VMVirtualServerClass();
I have tried different combinations for CoInitializeSecurity, but with no
success.
Does anybody has experience of accessing a Virtual Server (COM) through
ASP.NET ? Or is there another usable interface to VS ?
Many thanks
Clas
--
The light at the end of the tunnel,
was switch off due to high costs.
你有没有看过这个?
http://msdn.microsoft.com /library/de...com_object.asp
有一个调用虚拟服务器的样本。
-
Girish Bharadwaj
http://msmvps.com/gbvb
" Clas Hortien" <豪***** @ hotmail.com>在消息中写道
news:ci ********** @ news1.wdf.sap-ag.de ...
Have you read this already?
http://msdn.microsoft.com/library/de...com_object.asp
That has a sample of calling virtual server.
--
Girish Bharadwaj
http://msmvps.com/gbvb
"Clas Hortien" <ho*****@hotmail.com> wrote in message
news:ci**********@news1.wdf.sap-ag.de...
你好,
我尝试访问本地虚拟服务器对象。
我有一个带有按钮和文本框的aspx页面,这是代码:
public class WebForm1:System .Web.UI.Page
{
受保护的System.Web.UI.WebControls.Button btnFillBox;
受保护的System.Web.UI.WebControls.TextBox txtHost;
受保护的系统。 Web.UI.WebControls.Label Label1;
公共枚举RpcAuthnLevel
{
默认= 0,
无= 1,
连接= 2,
Call = 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
公共枚举RpcImpLevel
{
默认= 0,
匿名= 1,
识别= 2,
模仿= 3,
代表= 4
}
<公共枚举EoAuthnCap
{无> = 0x00,
MutualAuth = 0x01,
StaticCloaking = 0x20,
Dyna micCloaking = 0x40,
AnyAuthority = 0x80,
MakeFullSIC = 0x100,
默认值= 0x800,
SecureRefs = 0x02,
AccessControl = 0x04,
AppID = 0x08,
Dynamic = 0x10,
RequireFullSIC = 0x200,
AutoImpersonate = 0x400,
NoCustomMarshal = 0x2000,
DisableAAA = 0x1000
}
[DllImport(" ole32.dll")]
public static extern int CoInitializeSecurity(IntPtr pVoid,int
cAuthSvc,IntPtr asAuthSvc,IntPtr pReserved1,RpcAuthnLevel
level,RpcImpLevel impers ,IntPtr pAuthList,int dwCapabilities,IntPtr
pReserved3);
#region Web窗体设计器生成的代码
覆盖保护的void OnInit(EventArgs e)
{
//
// CODEGEN:ASP.NET Web Form
Designer需要此调用。
//
InitializeComponent();
base.OnInit( e);
}
///< summary>
///支持Designer的必需方法 - 不要mod ify
///使用代码编辑器的方法的内容。
///< / summary>
private void InitializeComponent()
{
这个。 btnFillBox.Click + = new System.EventHandler
(this.btnFillBox_Click);
this.Load + = new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender,System.EventArgs e)
{
this.txtHost.Text ="" ;;
CoInitializeSecurity(IntPtr.Zero,-1,IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.PktIntegrity,
RpcImpLevel.Identify,IntPtr.Zero,0x40,IntPtr.Zero ); VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
我总是得到一个拒绝访问 on vs = new VMVirtualServerClass();
我已经为CoInitializeSecurity尝试了不同的组合,但没有成功。
是否有人有通过访问虚拟服务器(COM)的经验
ASP.NET?或者VS有另一个可用的界面吗?
非常感谢
Clas
-
隧道尽头的灯光,
由于成本高而被关闭。
Hello,
i try to get access to a local virtual server object.
I have a aspx page with a button and textbox, this is the code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnFillBox;
protected System.Web.UI.WebControls.TextBox txtHost;
protected System.Web.UI.WebControls.Label Label1;
public enum RpcAuthnLevel
{
Default = 0,
None = 1,
Connect = 2,
Call = 3,
Pkt = 4,
PktIntegrity = 5,
PktPrivacy = 6
}
public enum RpcImpLevel
{
Default = 0,
Anonymous = 1,
Identify = 2,
Impersonate = 3,
Delegate = 4
}
public enum EoAuthnCap
{
None = 0x00,
MutualAuth = 0x01,
StaticCloaking= 0x20,
DynamicCloaking= 0x40,
AnyAuthority= 0x80,
MakeFullSIC= 0x100,
Default= 0x800,
SecureRefs= 0x02,
AccessControl= 0x04,
AppID= 0x08,
Dynamic= 0x10,
RequireFullSIC= 0x200,
AutoImpersonate= 0x400,
NoCustomMarshal= 0x2000,
DisableAAA= 0x1000
}
[DllImport("ole32.dll")]
public static extern int CoInitializeSecurity( IntPtr pVoid, int
cAuthSvc,IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel level, RpcImpLevel impers,IntPtr pAuthList, int dwCapabilities, IntPtr
pReserved3 );
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form
Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnFillBox.Click += new System.EventHandler
(this.btnFillBox_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
[STAThread]
private void btnFillBox_Click(object sender, System.EventArgs e)
{
this.txtHost.Text = "";
CoInitializeSecurity( IntPtr.Zero, -1, IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.PktIntegrity ,
RpcImpLevel.Identify,IntPtr.Zero, 0x40, IntPtr.Zero );
VMVirtualServerClass vs;
vs = new VMVirtualServerClass();
this.txtHost.Text = vs.Version;
}
}
}
I always get a "Access denied" on vs = new VMVirtualServerClass();
I have tried different combinations for CoInitializeSecurity, but with no
success.
Does anybody has experience of accessing a Virtual Server (COM) through
ASP.NET ? Or is there another usable interface to VS ?
Many thanks
Clas
--
The light at the end of the tunnel,
was switch off due to high costs.
嗨尼古拉斯:
其实,在在这种情况下,Girish指出的文档说:
多线程公寓模型应该用于应用程序
使用虚拟服务器COM接口。使用具有Virtual Server COM接口的单线程
公寓模型可以显着影响Virtual Server系统的性能。
>
在这种情况下OP不想设置aspcompat =" true"
-
Scott
< a rel =nofollowhref =http://www.OdeToCode.comtarget =_ blank> http://www.OdeToCode.com
周一,20日2004年9月09:09:28-10:00,Nicholas Paldino [.NET / C#MVP]"
< mv*@spam.guard.caspershouse.com>写道:
Hi Nicholas:
Actually, in this case the documentation Girish pointed to says:
"The multithreaded apartment model should be used for applications
using the Virtual Server COM interfaces. Using the single-threaded
apartment model with the Virtual Server COM interface can
significantly affect the Virtual Server system''s performance."
In which case the OP would not want to set aspcompat="true".
--
Scott
http://www.OdeToCode.com
On Mon, 20 Sep 2004 09:09:28 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
Clas,
为什么要调用CoInitializeSecurity?由于您正在调用COM
对象,您是否将ASPCompat属性设置为true?此外,
对象是否执行任何需要文件或注册表访问的内容?
您可能需要冒充有权访问虚拟服务器的用户。
Clas,
Why are you calling CoInitializeSecurity? Since you are calling a COM
object, are you setting the ASPCompat attribute to true? Also, does the
object do anything that requires file or registry access?
Chances are you will have to impersonate a user that has the rights to
access virtual server.
Hope this helps.
这篇关于ASP.NET中的CoInitializeSecurity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!