充分利用服务器的Windows登录名 [英] Getting the Windows login name from server

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

问题描述

我一直停留在这个问题上了好几天 - 任何帮助深表感谢。

I've been stuck on this issue for several days - any help is much appreciated.

我有在叫用C#编写DLL中的SQL触发器。在此功能,我需要登录源自激发触发器的SQL命令的人的名字的窗口。不要紧,我是否可以得到从C#或SQL这个信息。

I have an SQL trigger that's calling a DLL written in C#. In this function, I require the windows login name of the person that originated the SQL command that fired the trigger. It doesn't matter whether I get this info from C# or SQL.

不幸的是大多数正常的路由都失败了我身上。

Unfortunately most of the normal routes have failed on me.

内置SQL函数NT_C​​LIENT()仅当SQL登录使用Windows身份验证工作。

Built in SQL function NT_CLIENT() only works if the SQL login is using Windows Authentication.

DLL将在服务器上运行,因此环境.UserName是不相关的WindowsIdentity.GetCurrent()。名称返回一个空字符串,除非数据库用户(线程鼻祖)是使用Windows身份验证。

The DLL is running on the server, and therefore Environment.UserName isn't relevant and WindowsIdentity.GetCurrent().Name returns an empty string unless the database user (thread originator) was using Windows Authentication.

我知道域名,IP地址和工作站名称。从这个我已经想通了如何获得在C#中的SID - 反正是有,我可以使用C#从信息的比特获得Windows登录名或有内置的功能,我错过了。

I know the domain name, the ip address, and the workstation name. From this I've figured out how to get the SID in C# - is there anyway I can get the Windows login name from those bits of information using C# or is there an SQL built in function that I missed?

编辑:
谢谢你让我知道SQL是这一问题的哑弹。我们所拥有的是,每个人都记录到数据库作为一个用户的客户端。我最后不得不做的就是让一个不安全的组件调用命令行功能WMIC。令人讨厌的解决方案,但是它完成了任务。再次感谢您的咨询。 :)

Thanks for letting me know SQL was a dud for this problem. What we have is a client that logs everyone into the DB as one user. What I ended up having to do was make an unsafe assembly that calls a command line function WMIC. Yucky solution, but it got the job done. Thanks again for the advice. :)

推荐答案

您有从客户代码作为参数的用户名通过。我们做的是从我们的客户端代码(网站和服务),每一个电话。

You have to pass in the user name from client code as a parameter. We do that is every call from our client code (web sites and services).

然而,即使这样,它不是一个触发可用,所以我使用CONTEXT_INFO。

However, even then it's not available in a trigger, so I use CONTEXT_INFO.

没有魔法,没有银弹我很抱歉。

No magic, no silver bullet I'm sorry.

您另外一个选择是看安全帐户委派/直通。的谷歌搜索 ......有很多好东西,可能比某个特定链接

Your one other option is to look at Security Account Delegation/Passthrough. Google search... there is a lot of good stuff, probably better than one specific link.

如果这是不可能的,你说你不能改变客户端代码,那么就不能这样做。数据根本就不可能。故意让应用程序架构

If this is not possible, and you say you can't change client code, then it can't be done. The data is simply not available: and deliberately so by the application architecture.

这篇关于充分利用服务器的Windows登录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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