且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

确定从服务登录的本地用户名

更新时间:2023-12-03 23:19:04

试试这个


Dim nc As System.Security.Principal.WindowsIdentity =

System.Security.Principal.WindowsIdentity.GetCurre nt


调试。 WriteLine(nc.Name)


Sachin Gusain


" Jm"写道:
Try this

Dim nc As System.Security.Principal.WindowsIdentity =
System.Security.Principal.WindowsIdentity.GetCurre nt

Debug.WriteLine(nc.Name)

Sachin Gusain

"Jm" wrote:
大家好

是否可以使用vb.net中的代码确定谁从
服务内登录到计算机?我发现一些代码似乎在vb6下工作,但在.NET下没有?非常感谢任何帮助

Hi All

Is it possible to determine who is logged onto a machine from inside a
service using code in vb.net ? I have found some code that seems to work
under vb6, but doesnt under .NET ? Any help is greatly appreciated

Thanks



Jm,
是否有可能使用vb.net中的代码确定谁从
服务中登录到计算机?
我认为你是指登录的交互式用户&不是

服务运行的帐户。


我确定它可能,但我不知道如何...

我发现一些代码似乎在vb6下运行,但在.NET下没有?
你能发布你的VB6代码和你尝试过的.NET代码吗?我怀疑你的Declare语句可能会出现问题,因此它不起作用。


希望这有帮助

Jay


" Jm" < JA ***** @ ihug.com.au>在消息中写道

新闻:cp ********** @ lust.ihug.co.nz ...大家好

是否有可能确定谁使用vb.net中的代码从
服务内部登录到某台机器?我发现一些代码似乎在vb6下工作,但在.NET下没有?非常感谢任何帮助

谢谢
Is it possible to determine who is logged onto a machine from inside a
service using code in vb.net ? I take it you mean the interactive user logged in & not the account the
service is running under.

I''m sure its possible, however I don''t know how...
I have found some code that seems to work
under vb6, but doesnt under .NET ? Can you post your VB6 code and your attempted .NET code I suspect there may
be a problem with your Declare statements, hence its not working.

Hope this helps
Jay

"Jm" <ja*****@ihug.com.au> wrote in message
news:cp**********@lust.ihug.co.nz... Hi All

Is it possible to determine who is logged onto a machine from inside a
service using code in vb.net ? I have found some code that seems to work
under vb6, but doesnt under .NET ? Any help is greatly appreciated

Thanks



嗨Sachin


该代码返回NT AUTHORITY SYSTEM,这不是我不需要的。

我需要代码来返回服务之外的用户


"萨钦&QUOT; &LT;萨**** @ discussions.microsoft.com&GT;在留言中写道

新闻:C2 ********************************** @ microsof t.com ...
Hi Sachin

That code returns NT AUTHORITY SYSTEM which isnt what i needed unforunately.
I need the code to return the loged on user outside of the service

"Sachin" <Sa****@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
试试这个

Dim nc As System.Security.Principal.WindowsIdentity =
System.Security.Principal.WindowsIdentity.GetCurre nt

Debug.WriteLine(nc.Name)

Sachin Gusain

Jm写道:
Try this

Dim nc As System.Security.Principal.WindowsIdentity =
System.Security.Principal.WindowsIdentity.GetCurre nt

Debug.WriteLine(nc.Name)

Sachin Gusain

"Jm" wrote:
大家好

是否可以使用vb.net中的代码确定谁从
服务内登录到计算机?我发现一些代码似乎在vb6下工作,但在.NET下没有?非常感谢任何帮助

Hi All

Is it possible to determine who is logged onto a machine from inside a
service using code in vb.net ? I have found some code that seems to work
under vb6, but doesnt under .NET ? Any help is greatly appreciated

Thanks