1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-07 19:13:20 +00:00

1. Added usernameToUserKey() to win-registry

2. Added getRawSessionAttribute() to user-sessions for Windows
This commit is contained in:
Bryan Roe
2019-11-05 13:35:49 -08:00
parent 6e9b165452
commit 9a84f82a50
3 changed files with 42 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@@ -249,6 +249,22 @@ function UserSessions()
return (ret);
};
this.getRawSessionAttribute = function getRawSessionAttribute(sessionId, attr)
{
var buffer = this._marshal.CreatePointer();
var bytesReturned = this._marshal.CreateVariable(4);
if (this._wts.WTSQuerySessionInformationW(0, sessionId, attr, buffer, bytesReturned).Val == 0)
{
throw ('Error calling WTSQuerySessionInformationW: ' + this._kernel32.GetLastError.Val);
}
var b = buffer.Deref().Deref(0, bytesReturned.toBuffer().readUInt32LE()).toBuffer();
var ret = Buffer.alloc(bytesReturned.toBuffer().readUInt32LE());
b.copy(ret);
this._wts.WTSFreeMemory(buffer.Deref());
return (ret);
}
this.getSessionAttribute = function getSessionAttribute(sessionId, attr)
{
var buffer = this._marshal.CreatePointer();

View File

@@ -222,6 +222,24 @@ function windows_registry()
this._AdvApi.RegCloseKey(h.Deref());
}
};
this.usernameToUserKey = function usernameToUserKey(user)
{
var sid = user;
if (typeof (user) == 'string')
{
var r = this.QueryKey(this.HKEY.LocalMachine, 'SAM\\SAM\\Domains\\Account\\Users\\Names\\' + user);
sid = r.default._type;
}
var u = this.QueryKey(this.HKEY.Users);
for(i in u.subkeys)
{
if(u.subkeys[i].endsWith('-' + sid))
{
return (u.subkeys[i]);
}
}
throw (user + ': Not Found');
};
}
module.exports = new windows_registry();