以下のコード スニペットを使用して、WCF サービスでクライアント ユーザー名を取得します。サーバーの 1 つで、間違ったクライアント名を取得しています。私のクライアントは Win7 で、ワークグループ構成で Server 2008R2 と通信しており、両方のマシンにユーザーDave
とDave_Admin
. どちらも Win7 の管理者であり、後者のみがサーバーの管理者です。問題は、クライアントを として起動Dave
し、サーバーがクライアントを として表示することですDave_Admin
。クライアントの Dave とサーバーの Dave_Admin として、接続の両側の ID をデバッグしました。クレーム リソースにもDave_Admin
SID が表示されます。
これが起こると私が想像できる唯一の2つの理由は
- サーバーはどういうわけか、私が疑うユーザー
Dave_Admin
を探しているか、またはDave
- セットアップ後、管理ユーザーの名前を に変更
Dave
しDave_Admin
、新しいユーザーDave
を標準ユーザーとして作成した可能性があります。
やったかもしれないという漠然とした記憶しかありませんが、やったかどうかはわかりません。c:\users
フォルダは正常に見えます。私がこれを行った場合、これが理由ですが、修正する方法はありますか?
ユーザーの名前を変更した後にこれが発生した場合、別の説明または修正手段がありますか?
OperationContext lContext = OperationContext.Current;
RemoteEndpointMessageProperty mEndpointMessageProperties = lContext.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
mIdentity = lContext.ServiceSecurityContext.WindowsIdentity;
mUserName = mIdentity.Name;
mIPAddress = mEndpointMessageProperties.Address;
mPort = mEndpointMessageProperties.Port;
mConsoleID = string.Format("IP:{0}Port:{1}", mIPAddress, mPort);
mCallbackInterface = lContext.GetCallbackChannel<IConsoleCallbacks>();
mAuthority = TxWcfServer.sSelf.Authorized(mIdentity); // get the user's authority from the WcfServer when they logged on
// show client information
if (AppSupport.IsLogLevel(LogLevel.WCF))
{
// show the various security contexts
var x = lContext.ServiceSecurityContext;
AppSupport.WriteLog(LogLevel.Note, "*** WCF WindowsIdentity is '{0}'.", x.WindowsIdentity.Name);
AppSupport.WriteLog(LogLevel.Note, "*** WCF PrimaryIdentity is '{0}'.", x.PrimaryIdentity.Name);
AppSupport.WriteLog(LogLevel.Note, "*** WCF IsAnonymous is '{0}'.", x.IsAnonymous);
foreach (ClaimSet claimset in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
{
foreach (System.IdentityModel.Claims.Claim claim in claimset)
{
// Write out each claim type, claim value, and the right. There are two
// possible values for the right: "identity" and "possessproperty".
AppSupport.WriteLog(LogLevel.Note, "*** WCF Claim Type: {0}, Resource: {1} Right: {2}",
claim.ClaimType, claim.Resource.ToString(), claim.Right);
}
}
}