Roxtar
New member
- Joined
- Apr 13, 2021
- Messages
- 4
- Programming Experience
- 10+
Hi,
programming an intranetapp i run into a hard nut with .net core.
App is hosted on IIS and should query any devices MMI in my domain.
Local it works like a charm and on the same machine with IISExpress. (not for remotemachines)
the code above is used to query given machine, but access is allways denied, but the user it comes from httpcontext has rights on that machine.
Can anyone give hints what i can do make it work? (No i don't wana use normal .NET)
My IIS is Configured: Classicmode and Identity: Impersonate
thank you very much
RoXtar
programming an intranetapp i run into a hard nut with .net core.
App is hosted on IIS and should query any devices MMI in my domain.
Local it works like a charm and on the same machine with IISExpress. (not for remotemachines)
C#:
var user = _httpContextAccessor.HttpContext.User;
var winUser = (WindowsIdentity)user.Identity;
IEnumerable<CimInstance> deviceQuery = null;
#pragma warning disable CA1416
await WindowsIdentity.RunImpersonatedAsync(
winUser.AccessToken,
// User action
async () =>
{
DComSessionOptions dcomOptions = new DComSessionOptions();
dcomOptions.Impersonation = ImpersonationType.Impersonate;
dcomOptions.PacketIntegrity = true;
dcomOptions.PacketPrivacy = true;
CimSession impSession = CimSession.Create(devicename, dcomOptions);
deviceQuery = impSession.QueryInstances("root\\cimv2", "WQL", "SELECT * FROM win32_operatingsystem");
}
);
#pragma warning restore CA1416
the code above is used to query given machine, but access is allways denied, but the user it comes from httpcontext has rights on that machine.
Can anyone give hints what i can do make it work? (No i don't wana use normal .NET)
My IIS is Configured: Classicmode and Identity: Impersonate
thank you very much
RoXtar
Last edited by a moderator: