Is it for local Users or in a Windows-Domain?
May you just use the administrator for executing some methods?
private bool doSomeThingWithAdministrativePrivilegs()
{
IntPtr token;
if (!NativeMethods.LogonUser(
<$user>,
<$domain>,
<$password>,
NativeMethods.LogonType.NewCredentials,
NativeMethods.LogonProvider.Default,
out token))
{
throw new Win32Exception();
}
try
{
IntPtr tokenDuplicate;
if (!NativeMethods.DuplicateToken(
token,
NativeMethods.SecurityImpersonationLevel.Impersonation,
out tokenDuplicate))
{
throw new Win32Exception();
}
try
{
using (WindowsImpersonationContext impersonationContext =
new WindowsIdentity(tokenDuplicate).Impersonate())
{
}
}
finally
{
if (tokenDuplicate != IntPtr.Zero)
{
if (!NativeMethods.CloseHandle(tokenDuplicate))
{
return false;
}
}
}
}
finally
{
if (token != IntPtr.Zero)
{
if (!NativeMethods.CloseHandle(token))
{
return false;
}
}
}
return true;
}
uncomment the win32exceptions and you can have a look if its really the privilegs that deny the access...