Access to a path denied trying to write and read a file in asp.net web application - file

I have file writing permission denied problem in my web application,
below is the error i'm getting
Access to the path 'c:\inetpub\wwwroot\autohyperlink\files\test.txt' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path 'c:\inetpub\wwwroot\autohyperlink\files\test.txt' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
the error is here
Line 130: FileStream file1 = new FileStream(Server.MapPath("~\files\test.txt"), FileMode.Create, FileAccess.Write);
how can i solve this problem
please help me
Thanks

I dont mean to be derisive but have you tried doing what it says and granting the worker process read/write access to that folder/file?

Related

Salesforce/Data Factory Authentication Error

Need to connect SFDC Sandbox to Azure Data Factory but getting the following error when setting up the linked service and testing the connection:
Error code9603
DetailsERROR [HY000] [Microsoft][Salesforce] (80) Unknown error received from SOAP response, potentially a problem with user privileges. ERROR [HY000] [Microsoft][Salesforce] (80) Unknown error received from SOAP response, potentially a problem with user privileges. Activity ID: ba13abc8-5490-4d7a-afd4-cf4d5ddf5e86.
I confirm the security token for this account has been reset, the SFDC account has been assigned a profile of privileges where 'API enabled' is selected. I have also tried to pass the credentials through Azure Key Vault when setting up the linked account in Data Factory.
Are there any other permissions in Salesforce required so that we can check if everything is selected?
How can we find out what this unknown SOAP error is?
As API Enable is checked, there must be a problem with user access or organization access.
Follow the steps below:
Goto Setup -> Permission sets -> Check the name -> Goto systems permissions -> click on manage assignments
Check whether the integration user is added to those permissions or not. If not, add now.
If the integration is not possible, then mostly your organization or the account using for the operation is not having the API access.
Check whether the organization or the account which is being used for this operation is having API access or not, by visiting Organization Edition

Drupal: rebuild permissions failed, site not accessible

i have run rebuild permissions on a Drupal site. (Drupal 7.59)
However it failed for some reason, now the site is completely inaccessible, it is saying "No front page content has been created yet."
The admin interface is also not accessible with error "Access denied, you donĀ“t have permissions to access this content."
Any ideas how to override this? I have complete access though ftp to the server.
Thanks
Martin
Solved:
- gone manually to SQL database, changed the local admin login
- logged in to site.xxx/?q=user with the just changed local credentials
- restored site with the rebuild permissions command, /admin/reports/status/rebuild

SqlException: Cannot open database

I have problem with the IIS itself it seems that the database could not authenticate. The error shows like this:
SqlException: Cannot open database "dbPEMCOLoan" requested by the login. The login failed.
Login failed for user 'WORKGROUP\IAMPRO$'.
The problem right now is that I don't have any workgroup on my computer. See picture below:
and also here is my connection string:
"ConnectionStrings": {
"PEMCOLoan": "Data Source=IAMPRO;Initial Catalog=dbPEMCOLoan;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;"
}
I'm a bit new with the asp.net core framework and I'm trying my best to do the research on my own to fix the issue and tried those suggestions but never of them work because I couldn't find the domain WORKGROUP\IAMPRO$ itself.
Any help would be very much appreciated! Thanks!
WORKGROUP\IAMPRO$ is the local machine user account your IIS Application Pool runs and thus is used for Integrated Security (specified in your connection string).
Configure your Application Pool to run under a different user that is already granted access to your database or create a new, dedicated user account.
Using a dedicated user account is considered best practice since it allows to grant the specific privileges needed (on database and OS) and your App will not break when the password of your own user account is changed.

Weird "Login failed for user 'sa': in Event viewer

I'm hosting my web application on an azure VM. I've created a new user for MSSQLSERVER which my application can use to access the remote SQL server on that machine (so i do not use the sa user in my application). I have no problems at all accessing it, but i accidentally opened the Event Viewer and I found that each time I log into my application I get tens of messages that say
"Login failed for user 'sa'. Reason: An error occurred while
evaluating the password. [client: ......]
I first thought that it was an intruder, but then I realized that this message appears once I login to my application.
Why could this message be shown ?
It is a state 1 issue, password validation gets done all-right, the problem is it is disabled for that user, in this case your MSSQLSERVER user or sa.
Try logging in with sa, and log out to refresh credentials . grant all permissions to new user that you created, and log in with your newly created user. This should solve the problem [make sure that error number is either of 18470 or 18456].

Replication with pull subscribers fails under Active Directory policy when using a dedicated replication account

I have a replication set up with pull subscribers and it's deployed in our corporate domain. I have requested to create a dedicated account to run this replication off of.
On a pull subscription client in Sql Agent job I get this error:
Message
Unable to start execution of step 1 (reason: Error authenticating proxy DOMAIN\username, system error: Logon failure: the user has not been granted the requested logon type at this computer. ('Access this computer from network')). The step failed.
Where DOMAIN - is my domain name and username is this replication username that I requested from our admins.
This replication user can access both the distributor and the share folder where snapshots are stored. It also has this specific permission 'Access this computer from network' inherited from the group it's in.
Anyone encounter this sort of problem?
It turned out that the requested user wasn't added to a group that has all the necessary permissions. And so I've been struggling with this problem for several hours at which point I decided to go to our network administrator and see to it that the user was actually in the proper group. So yeah, I guess the message is right, a user has to have this permission 'Access this computer from network'. So, this basically answers my own question. Phew!

Resources