JIJIL
JIJIL

Reputation: 81

Unable to read the files from shared folder

I am trying to access files from the shared folder(ftp location) in Asp.net application. It is working fine from visual studio. When i deploy same in IIS 7 , i am getting the following error

"Logon failure: the user has not been granted the requested logon type at this computer."

Stack Trace:

[IOException: Logon failure: the user has not been granted the requested logon type at this computer. ]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +9723522 System.IO.FileSystemEnumerableIterator1.CommonInit() +245 System.IO.FileSystemEnumerableIterator1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler) +556
System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption) +64 System.IO.DirectoryInfo.GetFiles() +14

......

My application pool is running in NETWORKSERVICE mode To which user in IIS i need to give the permission for accessing this folder? is it IUSER or NT AUTHORITY\NETWORK SERVICE ? How can i identify the current running user in IIS?

Upvotes: 0

Views: 1489

Answers (3)

Alexei Levenkov
Alexei Levenkov

Reputation: 100610

To debug - look at Environment.UserName at the moment of exception. It will be either user that initiated request OR anonymous user.

To fix: if local files - granting permissions may be ok. If remote and using user's impersonated account - need to impersonate with another account that have permissions on remote machine as you can't use already impersonating account to access remote resource ("NTLM one hop").

Note: make sure you review security requirements when allowing access to files.

Upvotes: 0

fredrik
fredrik

Reputation: 6638

The reason the connection is refused it most likely a Group Policy which disallows access to that service by the user running the IIS service.

I would not want to give any of those system users permission to access a network resource. Other computers could potentially connect as well.

Instead - make your program authenticate with a guest account or another account which you create and give the appropriate permissions.

I would say that it would be a more secure approach.

Upvotes: 2

user1193035
user1193035

Reputation:

You may be trying to log on interactively to a computer you can only access over a network, or vice versa.

Change your logon location. Try to log on either locally (interactively) or remotely (over the network), as appropriate. You may want to ask the person who administers computer security to change the security database so you can log on either locally or remotely.

Upvotes: 0

Related Questions