2011-09-13 5 views
2

내가 파일 사용 권한을 설정하려면 다음 코드 (from msdn)이 있습니다 (I 해봤 내가 그룹 IIS_IUSRS를 사용하여이 전화변경 파일 권한 결과

' Adds an ACL entry on the specified file for the specified account. 
Sub AddFileSecurity(ByVal fileName As String, ByVal account As String, ByVal rights As FileSystemRights, ByVal controlType As AccessControlType) 

    ' Get a FileSecurity object that represents the 
    ' current security settings. 
    Dim fSecurity As FileSecurity = File.GetAccessControl(fileName) 

    ' Add the FileSystemAccessRule to the security settings. 
    Dim accessRule As FileSystemAccessRule = New FileSystemAccessRule(account, rights, controlType) 

    fSecurity.AddAccessRule(accessRule) 

    ' Set the new access settings. 
    File.SetAccessControl(fileName, fSecurity) 

End Sub 

ComputerName/IIS_IUSRS도) 나는 FileSystemRights.FullControl

을 적용하려고 그러나있어이 오류가 발생합니다 :

System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated 

이것은 IIS_IUSRS가 존재하지 않는다는 것을 의미합니다. 내 다음 단계는 컴퓨터에 사용자와 그룹을 출력하여 내 코드가 생각하는 것을 확인하는 것입니다. 뜻있는 시간에 누군가가 왜, 또는 이것을 일으키는 지 알 수 있습니까?

이 코드는 내 로컬 컴퓨터에서 제대로 작동하지만 내 웹 서버에서 실행할 때는 그렇지 않습니다. 응용 프로그램 풀은 네트워크 서비스로 실행되며 네트워크 서버는 파일이 들어있는 폴더에 대한 전체 권한을 가지고 있습니다. 사용자가 디렉토리에 대한 권한이 필요하다는 것을 알리는 this question을 발견했지만 문제는 아닙니다.

답변

0

이 문제를 해결하려면 익명과 달리 "응용 프로그램 풀과 동일하게"실행되도록 웹 사이트의 인증을 변경하십시오. 가장 좋은 대답은 아니지만 다른 모든 것을 시도했습니다.