开发者

WCF - Transport Authentication - Get Credentials of Authenticated User

开发者 https://www.devze.com 2023-01-07 11:15 出处:网络
I have a NetTcpBinding with SecurityMode.TransportWithMessageCredential. Transport.ClientCredentialType is set to MessageCredentialType.Windows, but I\'m considering MessageCredentialType.UserName.

I have a NetTcpBinding with SecurityMode.TransportWithMessageCredential.

Transport.ClientCredentialType is set to MessageCredentialType.Windows, but I'm considering MessageCredentialType.UserName.

Then there's a class DataStoreServerProxy for fetching database data which implements IDataStoreContract.

It contains methods such as this one:

Private Function Common_IDataStoreContract_ModifyData(ByVal ParamArray dmlStatements As ModificationStatement()) As ModificationResult Implements IDa开发者_如何学GotaStoreContract.ModifyData
        Return wrappedDataStore.ModifyData(dmlStatements)
    End Function

In order to get to that DB point, user must have already supplied the credentials. The question is, how to obtain them in those methods? Depending on the user name, I have to decide whether to allow access to some tables or not.


Username can be retrieved using OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name

0

精彩评论

暂无评论...
验证码 换一张
取 消