Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using the client under IIS the application name is not available due to security restrictions. [DNET213] #221

Closed
firebird-automations opened this issue Feb 20, 2009 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: Gareth Goslett (gareth)

Attachments:
FbConnectionInternal.patch

A website setup in IIS with "Anonymous Authentication" and "http://ASP.NET Impersonation" using the .Net provider generates the following error when connecting.

System.ComponentModel.Win32Exception: Access is denied

[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited) +955456
System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly) +126
System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId) +33
System.Diagnostics.Process.get_MainModule() +64
FirebirdSql.Data.FirebirdClient.FbConnectionInternal.BuildDpb(IDatabase db, FbConnectionString options) in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionInternal.cs:540
FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionInternal.cs:225
FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionPool.cs:201
FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionPool.cs:161
FirebirdSql.Data.FirebirdClient.FbConnection.Open() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnection.cs:612
System.Data.Firebird.FirebirdDatalayer.ExecuteReader(CommandType commandType, String commandText, IParameterList commandParameters, ITransaction commandTransaction) in d:\Projects\Libraries\Primitive\Primitive.Data\Data\Firebird\FirebirdDatalayer.cs:616
System.Data.DatalayerHelper.DataReadTypes(IDatalayer database, ITransaction transaction, IParameterList parameterList, TypeReader`1 readerMethod, String statementName) in d:\Projects\Libraries\Primitive\Primitive.Data\Datalayer\DatalayerHelper.cs:561
TimeLogsBl.Project.Load(Int32 year) in c:\Projects\Tinkering\TimeLogs\TimeLogsBl\Project.cs:206
TimeSheet.RefreshProjects() +124
TimeSheet.Page_Load(Object sender, EventArgs e) +560
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Commits: a7d0b9b

@firebird-automations
Copy link
Author

Modified by: Gareth Goslett (gareth)

description: In the method:
private DatabaseParameterBuffer BuildDpb(IDatabase db, FbConnectionString options)
line +- 538, dpb.Append(IscCodes.isc_dpb_process_name, Process.GetCurrentProcess().MainModule.FileName);

Generates a security exception and you can not connect.
I wrapped it in a try catch block and is working now.

#⁠if (NET_CF)
// for CF we can implement GetModuleFileName from coredll
#⁠else
try
{
dpb.Append(IscCodes.isc_dpb_process_name, Process.GetCurrentProcess().MainModule.FileName);
}
catch(Exception)
{
dpb.Append(IscCodes.isc_dpb_process_name, "Probably IIS");
}
#⁠endif

=>

A website setup in IIS with "Anonymous Authentication" and "http://ASP.NET Impersonation" using the .Net provider generates the following error when connecting.

System.ComponentModel.Win32Exception: Access is denied

[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited) +955456
System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly) +126
System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId) +33
System.Diagnostics.Process.get_MainModule() +64
FirebirdSql.Data.FirebirdClient.FbConnectionInternal.BuildDpb(IDatabase db, FbConnectionString options) in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionInternal.cs:540
FirebirdSql.Data.FirebirdClient.FbConnectionInternal.Connect() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionInternal.cs:225
FirebirdSql.Data.FirebirdClient.FbConnectionPool.Create() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionPool.cs:201
FirebirdSql.Data.FirebirdClient.FbConnectionPool.CheckOut() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnectionPool.cs:161
FirebirdSql.Data.FirebirdClient.FbConnection.Open() in c:\Projects\Tinkering\SqlManager\FirebirdClient\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbConnection.cs:612
System.Data.Firebird.FirebirdDatalayer.ExecuteReader(CommandType commandType, String commandText, IParameterList commandParameters, ITransaction commandTransaction) in d:\Projects\Libraries\Primitive\Primitive.Data\Data\Firebird\FirebirdDatalayer.cs:616
System.Data.DatalayerHelper.DataReadTypes(IDatalayer database, ITransaction transaction, IParameterList parameterList, TypeReader`1 readerMethod, String statementName) in d:\Projects\Libraries\Primitive\Primitive.Data\Datalayer\DatalayerHelper.cs:561
TimeLogsBl.Project.Load(Int32 year) in c:\Projects\Tinkering\TimeLogs\TimeLogsBl\Project.cs:206
TimeSheet.RefreshProjects() +124
TimeSheet.Page_Load(Object sender, EventArgs e) +560
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

@firebird-automations
Copy link
Author

Commented by: Gareth Goslett (gareth)

A patch to retrieve the application domain name in case of failure to access the process.
I wrapped both calls in try / catch as getting the process name should not cause a connection failure.

@firebird-automations
Copy link
Author

Modified by: Gareth Goslett (gareth)

Attachment: FbConnectionInternal.patch [ 11400 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

We should detect this in advance and not use try-catch for it. It hurts performance.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.0 Beta 2 [ 10340 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants