I have a WCF service that will use basic authentication and would like to determine who "who" is trying to use this service. I know that HttpContext.Current is NULL in the WCF service, but does not know that the alternative is to get a username.
userName = HttpContext.Current.Request.ServerVariables["LOGON_USER"];
Something like this maybe?
string login = OperationContext.Current .ServiceSecurityContext .PrimaryIdentity .Name;
Obviously, this helps to check for null reference exceptions along this path, but you get the idea.
OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name