如何模拟Nservicebus [英] How to impersonate Nservicebus

查看:43
本文介绍了如何模拟Nservicebus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何模拟 Nservicebus.我正在使用 Nservicebus 5.2 版本.

Hi How to impersonate Nservicebus. I am using Nservicebus 5.2 version.

我看到一些旧版本的代码,但在新版本中不可用.我们是否有一些示例来演示 5.2 版本中的模拟.

I see some code for old version but that is not available in new version. Do we have some sample which demonstrate the impersonate in 5.2 version.

 Configure.With()
        .StructureMapBuilder()
        .Sagas()
        .RunTimeoutManager()
        .UnicastBus()
           .ImpersonateSender(false)

新版本无法设置

模拟发送者

有谁知道如何将确切的当前主体对象传递到 END 点?

Does anyone know how to pass the exact currentprincipal object up to END points?

我尝试通过以下命令行启动我的端点.启动 NServiceBus.Host.exe/displayName:"myservice"/username:"mydomain\myname"/password:"mypwd"

I tried to start my endpoint by below command line. Start NServiceBus.Host.exe /displayName:"myservice" /username:"mydomain\myname" /password:"mypwd"

但是,当我登录 userName 时,它​​选择的用户名与我用来启动端点的用户名不同.

However when I log userName then it is not picking the same username which I used to start endpoint.

  public void Customize(BusConfiguration configuration)
        {


            configuration.UsePersistence<RavenDBPersistence>()

            Console.WriteLine("-------------------NAME--------------\n");
            Console.WriteLine(WindowsIdentity.GetCurrent().Name);
            Console.WriteLine("-------------------NAME--------------\n");


            Console.WriteLine("-------------------NAME--------------\n");
            Console.WriteLine(Thread.CurrentPrincipal.Identity.Name);
            Console.WriteLine("-------------------NAME--------------\n");
        }

输出如下:-------------------名称--------------

output comes like: -------------------NAME--------------

MYNetworkDomain\MyMachineLoggedInNTId-------------------名称--------------

MYNetworkDomain\MyMachineLoggedInNTId -------------------NAME--------------

-----------NAME--------------

-------------------NAME--------------

-----------NAME--------------

-------------------NAME--------------

推荐答案

.Net 中的模拟可以有多种风格,并且最终可能不会像您预期的那样运行.在 v4 中,当 .ImpersonateSender(...) 设置为 true 时,行为是与消息一起传递,使用消息头,在发送方端点使用的身份名称,接收方将使用传入消息头以设置新的通用身份.

Impersonation in .Net can have many flavors and may not end up behaving as you might expect. In v4 when .ImpersonateSender(...) was set to true the behavior was to deliver along with the message, using a message header, the identity name used at the sender endpoint, the recipient would have used the incoming message header to set up a new generic identity.

这不是真正的模拟,更不用说跨不同机器工作的模拟需要设置委派,以及委派带来的所有安全问题.更不用说,AFAIK,Windows Identity 模拟无法在线程级别完成,安全令牌附加到进程并且不能被伪装成不同用户的线程覆盖.

It is not a real impersonation, not to mention that impersonation to work across different machines requires delegation to be set up, with all the security concerns that delegation brings to the table. Not to mention that, AFAIK, Windows Identity impersonation can't be done at the thread level, the security token is attached to the process and can't be overwritten by a thread pretending to be a different user.

也就是说,没有什么能阻止您构建自己的逻辑来传递身份和消息,以便根据需要设置 .Net 身份/主体基础设施,并能够通过 Role 基础设施.

That said, nothing prevents you to build your own logic to deliver identities along with messages in order to have .Net identity/principal infrastructure setup as you like and be able to perform security checks via the Role infrastructure.

这篇关于如何模拟Nservicebus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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