Get current Windows user name within Silverlight

前端 未结 8 1782
一向
一向 2020-12-02 23:53

Is it possible to get the currently logged in user\'s username with Silverlight? You can assume that user has Windows OS and the Silverlight application is hosted in Interne

8条回答
  •  眼角桃花
    2020-12-03 00:24

    The highly voted answers to this question did not help me.

    Using an ASP.NET web service, this worked however:

    string userName =
       System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity.Name;
    

    And this blog entry is the one that set me on the correct path:

    http://rouslan.com/2009/03/12/20-steps-to-get-together-windows-authentication-silverlight-and-wcf-service/

    ServiceReferences.ClientConfig needs this:

      
        
          
            
              
            
          
        
     
    

    And web.config needs this:

      
        
        
      
    
      
        
          
            
              
                
              
            
          
        
      
    

    Those are the only noteworthy changes I needed to make to an otherwise working Silverlight application that previously used anonymous access for web services in IIS.

提交回复
热议问题