다른 Windows 사용자 ID로 실행하려면 내 코드를 가장해야합니다. 지금은 웹에서 일부 기본 라이브러리를 호출하는 일부 코드를 사용하고 있습니다.Windows 7에서 C# 코드를 가장합니다
코드 목적은 파일 서버 사용자 디렉토리 권한에 대한 권한을 변경하는 것입니다.
내 폴더 권한을 변경할 수는 있지만 다른 사용자의 자격 증명이 있어야 자신의 폴더에 대한 권한을 변경할 수 있습니다. 하지만 나는 그를 흉내내어 컴퓨터에서 코드를 실행하고 있습니다.
하지만 승인되지 않은 예외가 발생합니다.
내가 사용하고있는 코드는 다음과 같습니다
[DllImport("advapi32.dll", SetLastError = true)]
private static extern int LogonUser(
string lpszUserName,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken);
나는이 Windows 7에서 작동되지 않았거나 확실하지 않다. 이런 문제에 직면 한 사람이 있습니까?
예외 난 점점 오전 :
Messagee:"{"Attempted to perform an unauthorized operation."}"
stack trace:
at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)
at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections)
at System.Security.AccessControl.FileSystemSecurity.Persist(String fullPath)
at System.IO.Directory.SetAccessControl(String path, DirectorySecurity directorySecurity)
at FolderAccessManager.Program.Main(String[] args) in
당신이 몇 가지 솔루션을 공유 시겠어요 ..?
예외에 대한 자세한 내용을 알려주십시오. –
예외 메시지와 함께 편집하십시오. – sbmandav
'runas'를 쓰지 않는 이유는 무엇입니까? –