gpt4 book ai didi

c# - AzMan 对不同的服务器给出不同的结果

转载 作者:太空宇宙 更新时间:2023-11-03 11:37:10 25 4
gpt4 key购买 nike

我们有 2 个网络服务器,它们理论上是相同的,但在执行 AzMan 授权检查时会产生不同的结果。

我们在两台机器上运行相同的网站(字面意思是相同的网站 - 它已从一台机器复制到另一台机器,并且在相同的服务帐户下运行)。该网站所做的只是对 AzMan 数据库(位于单独的 SQL 服务器上)执行授权检查。

但是,在工作网站 (WebA) 上,此检查返回 0(即“用户已获得授权”),而在损坏的网站 (WebB) 上,此检查返回 5(即“用户未获得授权”)。我们期待两个网站上的 0。同一用户从同一台 PC 访问两个网站。

有没有人对我们可以检查的东西有任何想法?

环境细节

  • window 服务器 2008 R2
  • 相同的 AD 域
  • IIS 7.5
  • .NET 3.5
  • AzMan 数据库在 SQL Server 2005/Windows Server 2008 R2 上运行。

代码

AzAuthorizationStoreClass authStore = new AzAuthorizationStoreClass();

// initialise the store
authStore.Initialize(0, "mssql://Driver={SQL Server};Server={OURDBSERVER};Trusted_Connection={Yes};/OURDATABASE/OURAPPLICATION", null);

// open the store
IAzApplication2 authApp = authStore.OpenApplication2("OURAPPLICATION", null);

// get the identity of the user NOT the service account
WindowsIdentity identity = Thread.CurrentPrincipal.Identity as WindowsIdentity;

// and from that derive the token
ulong userToken = (ulong)identity.Token.ToInt64();

// get the context based on the token
IAzClientContext3 clientContext =
(IAzClientContext3)authApp.InitializeClientContextFromToken(userToken, null);

// get the operation object based on the id
IAzOperation2 azManOperation = (IAzOperation2)authApp.OpenOperation(operationId, null);

// generate an audit identifier
string auditIdentifer =
string.Format("{0}{1} : O:{2}", "{the_correct_id}", identity.Name, operationId);

uint accessResult = clientContext.AccessCheck2(auditIdentifer, string.Empty, azManOperation.OperationID);

return accessResult.ToString();

非常感谢,

RB.

最佳答案

感谢 David Hall 为我指明了正确的方向。

调查表明,这两个网站都启用了 Windows 身份验证和匿名访问。但是,在一个网站上,用户可以正确登录,而在损坏的网站上,用户会退回到匿名模式。

通过确保用户登录到两个网站,禁用匿名访问解决了这个问题。

然而,这留下了另一个问题,即为什么浏览器在一个网站上匿名登录而不是另一个网站 - 我认为一个是针对 ServerFault。

关于c# - AzMan 对不同的服务器给出不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5895150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com