阅读:2203回复:5
请教高手~如何在内核中通过SID得到用户名?
最近一直困扰在这个问题上面,已经可以取到用户的SID,但是不知道应该怎么通过SID取得用户名呢?
刚刚看到在用户模式下可以调用LookupAccountSid这个函数,那么在内核模式中应该调用什么函数得到呢?? 请各位多多指教~~ |
|
沙发#
发布于:2007-04-05 08:45
LSA:Local Security Authority
你看下windows 2K的关于LookupAccountSid代码就知道在内核层来获取估计是不可能的, 因为系统是通过查询“LSA Policy Database”来获取SID和NAME的对应关系的, 而查询“LSA Policy Database”在内核层好像没有接口可用。 不过你可以让KERNEL和APP交互来让APP获取会更简单些 |
|
|
板凳#
发布于:2007-04-05 08:59
integral subsystem
A protected subsystem (server) that performs an essential operating system task. The integral subsystems include the Local Security Authority, the Security Accounts Manager, the Session Manager, and the network server. See also protected subsystem. protected subsystem A server that appears to perform operating system functions for its native applications and subsystem-specific drivers by calling system services. A protected subsystem runs in user mode and its interface to end users emulates another operating system, such as Windows or POSIX, on top of the NT kernel. See also integral subsystem. 保护子系统运行在用户态! |
|
|
地板#
发布于:2007-04-05 16:47
//
// Get TokenSource Name If SourceName is "NtLmSsp" it was logged-in via Lanmanager, // "User32" represents localy logged-in users. // __try { status = SeQueryInformationToken(pToken,TokenSource,&pTokenSrc); if (NT_SUCCESS(status)) { pTokenSrc->SourceName[TOKEN_SOURCE_LENGTH-1] = 0x00; if (_stricmp(pTokenSrc->SourceName,"NtlmSsp") == 0) { return TRUE; } } } __finally { if (pTokenSrc) { ExFreePool(pTokenSrc); } } |
|
地下室#
发布于:2007-04-06 11:16
这样取到的是真正的用户名吗?
我用了GetSecurityUserInfo这个函数 但是和我用的一个硬件的打开模块相冲突,我用了这个函数那个模块就不能打开了 把那个函数屏蔽掉就可以了。。。。 |
|
5楼#
发布于:2007-04-06 11:47
bluacat的方法能区分是网络访问还是本地访问,但却得不到SID对应的用户名。
|
|
|