native-win-js-for-fun

Addon containing some native (COM) Functions

Usage no npm install needed!

<script type="module">
  import nativeWinJsForFun from 'https://cdn.skypack.dev/native-win-js-for-fun';
</script>

README

WIN-IMPERSONATOR-JS

Codacy Badge

Impersonator for Windows

Impersonator Object Factory with 2 public functions, "impersonateUser" and "stopImpersonation"

Calling COM Functions

Reimplementing Code originally written by Simon Buchan https://github.com/simonbuchan/native-users-node (Thanks a lot!)

Usage

import {createObject, LogonProvider, LogonType} from "native-win-js-for-fun";

...
let impersonator = createObject(userName, password, domain);

//impersonating Windows Account, calling functions LogonUserW and also ImpersonateLoggedOnUser
impersonator.impersonateUser(LogonType.NETWORK, LogonProvider.WINNT50);

//stop Impersonation, calling functions RevertToSelf and then closing handle
//This function must be called, otherwise handle will not be closed!!!
impersonator.stopImpersonation();