确定从服务登录的本地用户名 [英] Determine Local Logged On UserName From Service

查看:54
本文介绍了确定从服务登录的本地用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


是否可以使用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

推荐答案

试试这个


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,这不是我不需要的。

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


"萨钦" <萨**** @ discussions.microsoft.com>在留言中写道

新闻: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



这篇关于确定从服务登录的本地用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆