标签: windows-identity

NServiceBus - 如何配置总线以允许WindowsIdentity从客户端流出

在客户端我已经设置了总线 ImpersonateSender(true)

我的服务器已配置AsA_Server,默认情况下应具有该服务器ImpersonateSender(true)

我现在正试图从Handler中检索WindowsIdentity

var windowsIdentity = WindowsIdentity.GetCurrent(true);
Run Code Online (Sandbox Code Playgroud)

但这让我无效.

我究竟做错了什么?

c# nservicebus windows-identity

4
推荐指数
1
解决办法
1379
查看次数

在我的WCF Web服务中获取WindowsIdentity

我接管了一个不再和我们在一起的开发人员的代码.它是一个最初使用传入用户名的WCF Web服务,但我们需要它来使用WindowsIdentity.

string identity = ServiceSecurityContext.Current.WindowsIdentity.Name;
Run Code Online (Sandbox Code Playgroud)

该代码最终返回一个空字符串.我正在使用安全(wsHttpSecure)绑定,因此ServiceSecurityContext.Current不是null或任何东西.我一直在寻找一天的解决方案,但还没有找到任何东西.

因为我是WCF的新手,所以我不确定其他相关信息是什么.以下是IIS中Web服务的启用身份验证设置:

Anonymous Authentication - Enabled
Windows Authentication - Enabled
Run Code Online (Sandbox Code Playgroud)

这是web服务的web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <connectionStrings>
        <clear />
        <add name="LocalSqlServer" connectionString="Data Source=.\instanceNameHere;Initial Catalog=default;Integrated Security=SSPI;"/>
    </connectionStrings>
    <appSettings configSource="appSettings.config" />
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
                <listeners>
                    <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\ServiceLogs\WebServiceLog.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
    <system.web>
        <trace enabled="true" />
        <membership defaultProvider="XIMembershipProvider" userIsOnlineTimeWindow="30">
            <providers>
                <clear/>
                <add name="XIMembershipProvider" type="LolSoftware.MiddleTier.BusinessLogic.XIMembershipProvider"
      applicationName="LolWebService"/>
            </providers>
        </membership>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
        <client />
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
        <behaviors configSource="behaviors.config" /> …
Run Code Online (Sandbox Code Playgroud)

https wcf web-services windows-identity

4
推荐指数
1
解决办法
9712
查看次数

CryptographicException:启用WIF的MVC 4中的数据无效

我创建了一个MVC 4项目并为Azure ACS设置它.它与System.Identity一起使用.我将其更改为使用Microsoft.Identity启用WIF,我的配置文件现在看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="microsoft.identityModel"
             type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <connectionStrings>

    <add name="DefaultConnection"  />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ida:FederationMetadataLocation" …
Run Code Online (Sandbox Code Playgroud)

c# security .net-4.0 windows-identity wif

4
推荐指数
1
解决办法
5855
查看次数

使用azure acs和mvc3时,检测用户登录的最佳位置是什么?

我希望能够检测用户何时使用被动ac登录我的应用程序,以便我可以将它们添加到我的数据库中,如果这是第一次使用我的应用程序.现在我正在订阅WSFederationAuthenticationModule.SignedIn,但我觉得我错过了什么.主要是我不确定订阅活动的最佳位置,我让它在PostAuthenticateRequest内部工作,但它有点hacky.有什么建议?

此代码来自global.asax

    public override void Init()
    {

        base.Init();

        PostAuthenticateRequest += (s, e) =>
        {
            try
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignedIn -= SignedIn;
            }
            finally
            {
                FederatedAuthentication.WSFederationAuthenticationModule.SignedIn += SignedIn;
            }

        };


    }


    private void SignedIn(object sender, EventArgs e)
    {
       //do something
    }
Run Code Online (Sandbox Code Playgroud)

编辑:

现在我将使用一个标志变量来确保我只订阅一次SignedIn.除非有人有任何其他建议:)感谢Sandrino的帮助.这就是我现在所拥有的.

    private static bool isFirstRequest = true;

    public override void Init()
    {


        base.Init();

        PostAuthenticateRequest += (s, e) => { 
        if (isFirstRequest)
        {
             FederatedAuthentication
                 .WSFederationAuthenticationModule.SignedIn += SignedIn;
             isFirstRequest = false;
        }

        };

    }


    private void SignedIn(object sender, EventArgs e)
    {

        //do something …
Run Code Online (Sandbox Code Playgroud)

azure windows-identity acs

3
推荐指数
1
解决办法
1938
查看次数

Windows Identity Foundation:如何在ASP.net中获取新的安全令牌

我正在编写一个使用Windows Identity Foundation的ASP.net应用程序.我的ASP.net应用程序使用基于声明的身份验证,并将被动重定向到安全令牌服务.这意味着当用户访问应用程序时,它们会自动重定向到安全令牌服务,在那里他们会收到一个安全令牌,用于向应用程序标识它们.

在ASP.net中,安全令牌存储为cookie.

我希望用户可以在我的应用程序中单击某些内容,删除cookie并将其重定向到安全令牌服务以获取新令牌.简而言之,可以轻松注销并以其他用户身份登录.我尝试在代码中删除包含令牌的cookie,但它会以某种方式持续存在.

如何删除令牌以便用户可以再次登录并获取新令牌?

asp.net cookies passive-sts windows-identity wif

1
推荐指数
1
解决办法
3346
查看次数

获取当前登录用户(FullToken上下文)

我有一个问题,就是......我用右键单击启动程序 - >以管理员身份运行.这意味着程序正在管理上下文中运行.

WindowsIdentity.GetCurrent().Name;
Run Code Online (Sandbox Code Playgroud)

如果我尝试获取用户名,我会得到启动程序的用户作为管理员...例如"管理员",但我需要的是当前登录用户的名称,例如:bob

有人可以帮帮我吗?:)

c# token windows-identity

1
推荐指数
1
解决办法
3203
查看次数

当前用户是LocalSystem Check?

很容易确定运行我的C#.NET 4.0控制台应用程序的用户是否是本地Administrators组的成员.我也在尝试确定它是否在LocalSystem下运行.最好的方法是什么?

security impersonation iprincipal windows-identity

1
推荐指数
1
解决办法
695
查看次数