简体   繁体   English

.net的geteuid()等价于什么?

[英]What's the .net equivalent of geteuid()?

I would like to check programmatically what is the effective user who owns the process, from inside that process, under windows. 我想以编程方式检查在Windows中从该进程内部拥有该进程的有效用户是什么。

Might be winapi, but a .net solution is preferable. 可能是winapi,但最好使用.net解决方案。

There is an complicated system of which I do not have a perfect control, an .net app gets 'access denied' to some network filesystem path, and hence I would like to know which user should get the privileges to access this path, so I need a user that owns the process which tries to access it. 我没有一个完美的控制复杂的系统,.net应用程序无法访问某些网络文件系统路径,因此我想知道哪个用户应该获得访问此路径的特权,所以我需要拥有尝试访问它的进程的用户。

with Windows APIs: 使用Windows API:

GetUserNameEx function GetUserNameEx函数

in C#: 在C#中:

WindowsIdentity.GetCurrent().Name;

Although not .net, the following article from the Unix to Windows Porting Dictionary on: 尽管不是.net,但以下文章是从Unix到Windows Porting Dictionary的:

uid_t getuid();
uid_t geteuid();

... is a good start to solving this problem. ……是解决这个问题的良好开端。

From that article: 从那篇文章:

A Unix process maintains a distinction between the UID of the user that started the process (the real UID) and the UID of the user that the process is running as (the effective UID). Unix进程在启动进程的用户的UID(实际UID)和运行该进程的用户的UID(有效UID)之间保持区别。 Windows does not maintain this distinction. Windows不保留此区别。 The value of a SID will be the equivalent of the Unix effective UID. SID的值将等效于Unix有效UID。 Since the equivalent of the Unix real UID cannot be obtained using the SID is recommended for Windows when the real or effective UID is needed. 由于建议在需要真实或有效UID的Windows中使用SID无法获得等效于Unix真实UID的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM