I have a WCF service which is accessing Sharepoint document library UNC path, Picking word file and converting to pdf using aspose.words and dropping the converted file to another document library using UNC path.
It's working fine when I run the service using VS WCF Test client and not working when I published the service to IIS. Appreciate your help.
Here is the error:
System.IO.IOException: Access Denied.
Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)\r\n at Aspose.Words.Document..ctor(String fileName, LoadOptions loadOptions)\r\n at Word2PdfSvc.Convert2Pdf.SavePdf(String sourceUrl, String srcFileName, String destinationUrl, String dstFileName)"
Related
I'm having a problem with NT Authority\Network Service not having sufficient permissions for executing some code in my SSIS Control flow VB.net script task. It executes perfectly within debug, but when I create a Job Agent to execute it, I receive the following error concerning the permissions for Network Service:
10/23/2015 15:36:59,Guest Satisfaction Subscriptions,Error,1,DILBERT,Guest Satisfaction Subscriptions,Guest Satisfaction Subscriptions,,Executed as user: TAYLORS\DILBERT$. Microsoft (R) SQL Server Execute Package Utility Version 10.50.2500.0 for 64-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. Started: 3:36:59 PM Error: 2015-10-23 15:37:03.37 Code: 0x00000001 Source: Generate and Save Reports Description: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: The permissions granted to user 'NT AUTHORITY\NETWORK SERVICE' are insufficient for performing this operation. ---> Microsoft.ReportingServices.Diagnostics.Utilities.AccessDeniedException: The permissions granted to user 'NT AUTHORITY\NETWORK SERVICE' are insufficient for performing this operation. at Microsoft.ReportingServices.WebServer.ReportExecution2005Impl.LoadReport(String Report<c/> String HistoryID<c/> ExecutionInfo2& executionInfo) at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report<c/> String HistoryID<c/> ExecutionInfo& executionInfo) at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message<c/> WebResponse response<c/> Stream responseStream<c/> Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName<c/> Object[] parameters) at ST_0378b6554b714d23a0b9474d41ce618e.vbproj.ReportServer.ReportExecutionService.LoadReport(String Report<c/> String HistoryID) at ST_0378b6554b714d23a0b9474d41ce618e.vbproj.ScriptMain.Main() --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target<c/> Object[] arguments<c/> SignatureStruct& sig<c/> MethodAttributes methodAttributes<c/> RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj<c/> BindingFlags invokeAttr<c/> Binder binder<c/> Object[] parameters<c/> CultureInfo culture<c/> Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj<c/> BindingFlags invokeAttr<c/> Binder binder<c/> Object[] parameters<c/> CultureInfo culture) at System.RuntimeType.InvokeMember(String name<c/> BindingFlags bindingFlags<c/> Binder binder<c/> Object target<c/> Object[] providedArgs<c/> ParameterModifier[] modifiers<c/> CultureInfo culture<c/> String[] namedParams) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 3:36:59 PM Finished: 3:37:03 PM Elapsed: 4.29 seconds. The package execution failed. The step failed.,00:00:04,0,0,,,,0
10/23/2015 15:36:00,Guest Satisfaction Subscriptions,Error,0,DILBERT,Guest Satisfaction Subscriptions,(Job outcome),,The job failed. The Job was invoked by User TAYLORS\administrator. The last step to run was step 1 (Guest Satisfaction Subscriptions).,00:00:05,0,0,,,,0
I've looked at multiple websites, and I've found the following discussed for NT Authority\Network Service, so I verified what I found on our system:
On the Reporting Services Configuration Manager - The service account is set to "Network Service"
Report Server Database Credentials (ReportServer DB) - NT Authority\Network Service is granted db_owner and RSExecRole
URL Site Settings - NT Authority\Network Service granted System Administrator and System User (by me to ensure that isn't the problem)
SQL Server Credentials (User Mappings) - NT Authority\Network Service is granted db_owner, public, RSExecRole for ReportServer Database
A snippet of the code that is attempting to run:
objParams(0) = objParamSelect
objParams(1) = objParamUnitID
'Define everything to run the SSRS report on the report server
With objRSExec
.Credentials = System.Net.CredentialCache.DefaultCredentials
.Url = "http://<<Server>>/ReportServer/ReportExecution2005.asmx"
.LoadReport("/<<Report Name>>", Nothing)
.SetExecutionParameters(objParams, "en-us")
objResult = .Render(strFileType, Nothing, strFileExtension, Nothing, Nothing, Nothing, Nothing)
End With
objStream = File.Create(strFullPathName, objResult.Length)
With objStream
.Write(objResult, 0, objResult.Length)
.Close()
End With
With the above code, I'm attempting to execute an SSRS report by calling our report server URL. The code seems to work well in debug mode, but I'm missing some permissions when executing from a Job Agent. Any help would be greatly appreciated. Thank you for your time!
Just in case anyone else is having this same problem, I wanted to post the answer to my own question. Even though I provided the "Home" folder on the ReportingServices website with complete control, it didn't trickle down into the individual folder containing the SSRS report. When I added "Network Service" to "Security" in that folder and provided it with simple "Browser" permissions, that fixed that error.
Environment: MS Windows Server 2003, IE9, MS Excel 2007.
Prerequisite: A user logs on to the server using a username and a password. When accessing internet through IE9 (or any other web browser) a dialog box is displayed requiring the username and the password (required by the server at Kerio Winroute Firewall).
Scenario: A user runs URLDownloadToFile function from Excel to download a .pdf file from the internet, function returns error E_ACCESSDENIED.
Question: How to execute file download from internet using URLDownloadToFile function from Excel without errors in the abovementioned scenario?
Old question, but one of the top Google hits for this problem.
I had to use a valid domain user name & password in the URL, like this:
sURL = "https://username:password#server.mydomain.com/path/file.pdf"
ret = URLDownloadToFile(0, sURL, sLocalFile, 0, 0)
In a DNN page containing ANYTHING that accesses custom data (i.e., site-specific tables), we always get the following error:
Access Is Denied
[Win32Exception (0x80004005): Access is denied] [SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6749670 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815
Current config:
IIS pool set up as a local service
SQL runs as a localsystem service
All of the users have the proper DB ownership
DB can be accessed OK for the main DNN install (i.e. users can log in and all DNN-related database infrastructure can be read and displayed from the database), but for the custom modules that read the Connection string from the web.config, it throws the error above.
We've tried to:
Change to poolidentity and give the permission to that particular user/service, and we are experiencing the same problem.
I'm not sure if IIS Application Pools or SQL users are the issue. The error seems to be about the SQL instance which may or may not be set up correctly. However, if it's an SQL instance issue, as per the error message, we are not sure why database access for DNN functions (login, tabs, modules, etc.) are allowed but other connections (via LINQ data context for site-specific schema, or via where we hard-code the connection string) are denied.
I cannot connect to SQL Server Database.
I am trying to setup Membership with roles on my website using the MSDN Tutorial. It used to work only locally on my machine, however after following advice given on different forums, and on stackoverflow, the situation worsened, and now I can't even connect to the SQL Server Database.
When I run the aspnet.regsql.exe utility, I get the following error message:
"Setup failed.
Exception:
Unable to connect to SQL Server database.
----------------------------------------
Details of failure
----------------------------------------
System.Web.HttpException: Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
--- End of inner exception stack trace ---
at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
at System.Web.Management.SqlServices.Install(String database, SqlFeatures features, String connectionString)
at System.Web.Management.ConfirmPanel.Execute()"
Also, I am unable to use the ASP.NET Website Adimistration Tool. When I click on the Security tab I receive the following error:
"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database."
So, I click on the 'Choose Data Store' button as instructed, which allows me to select a a Provider. The provider is named 'AspNetSqlProvider', it has a Test link beside it. I click on Test and receive the following error message:
"Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."
The only other option on this page is to click "Back".
Can somebody please help me sort this out? It's been over a week now and I've searched high and low for answers and have been given so many links to posts that have been of no help. I'd appreciate any help at all.
I have tried running the Configuration Surface Tool and enabling pipes, local/remote connections, though this has made no difference at all.
I have even gone so far as to completely uninstall Visual Web Developer and SQL Server 2005 and 2008 and delete all traces left behind of these applications, and then re-downloaded them all and re-installed them all again.
No luck so far.
Please help
Thanks
Bael
Edit:
I have since tried disabling my firewall changing the port, with no luck.
SOLUTION:
Yes, this may be a little drastic. And I think that this solution should only be a last resort when all else fails.
I managed to fix whatever was wrong by uninstalling SQL Server 2005 and 2008. And then Registering for, downloading SQL Server Express Edition 2008 (with Management Tools) and installing them.
After installation was complete, I closed Visual Web Developer, opened it again, and clicked on the Security tab after opening ASP.NET Website Administration Tool and everything has just "worked" since...
Can you connect using sqlcmd locally?
Can you connect using sqlcmd from a remote machine?
Are you using a SQL username/password, or trusted Windows authentication? If the latter, run CommandPrompt/Powershell as a different user and see if you can connect.
My guess is that you haven't added logins to SQL, and that you're running aspnet.regsql.exe without escalated privileges. If it runs successfully from a Command Prompt that was Run As Administrator, then this is a useful sign.
There are a number of potential issues, but the escalated privileges is something I see often these days. It's better to create a dedicated account, give that an appropriate amount of access to the SQL instance, and then run Command Prompt as that account (shift-right-click to get the old 'Run as' option).
I have a .NET 3.5 C# library that uses OleDb to pull data from an Excel file and return it in a DataRowCollection which is used by a CLR Table-Valued Function in SQL Server 2005.
I deployed the ASSEMBLY in SQL Server as sa and used PERMISSION_SET = EXTERNAL_ACCESS. The sa login has EXTERNAL ACCESS ASSEMBLY and the database has TRUSTWORTHY on.
The assembly is signed and I used the following caspol.exe command which indicated that it was successful:
-m -ag All_Code -url "C:\Testing\sqlFunction.dll" FullTrust -n "sqlFunction"
The SQL Server instance, my library and the Excel document are all on the same machine.
The SQL Server service is running as Local System (but while trying to get this to work I also tried running it as the AD user that I was logged in as which is also a local administrator).
I created a command line application to test run the library and everything runs fine and data is returned as expected.
But when I run the function from SSMS, I get this error in the result pane:
A .NET Framework error occurred during execution of user-defined routine or aggregate "GetExcelFile":
System.Security.SecurityException: Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.OleDb.OleDbConnection.PermissionDemand()
at System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at GetExcelFunction.GetFile()
at GetExcelFunction.InitMethod(String logname)
I've deployed this on my personal dev machine (XP PRO) and our dev sandbox (Server 2003) and got the same error.
Most code access security issues revolve around the assembly running from a network share - but that's not the case here.
Any ideas? I'm tapped out.
Solved it!
PERMISSION_SET = EXTERNAL_ACCESS was not enough. I had to go all the way down to PERMISSION_SET = UNSAFE and then it started working. I can't believe I didn't try that before.
I am sorry that I am not providing a solution to the exact problem here.
But, you can use OPENROWSET function to work with Excel files from SQL Server.
CLR is not necessary, unless there is something that I don't know of.
I am looking the code using reflector. And I am purely speculating looking at the code.
Try initializing System.Data.OleDb.OleDbPermission class & use it's Add method to include the excel connection string to have permission (either before connection opens or query execution).
I hope that helps.