WCF Service, Windows Authentication

前端 未结 2 1360
日久生厌
日久生厌 2020-12-12 02:49

we wrote a WCF service, deployed on IIS. we chose Integrated Windows Authentication. service can not be used in this case but if we can set the authentication method of the

2条回答
  •  粉色の甜心
    2020-12-12 03:06

    You have to do a few things:

    • Uncheck the anonymous access from your Virtual forlder and check Integrated windows security.
    • Create the following binding configuration:

        
       
          
              
          
       
       
      
    • Apply the above configuration to your service and mex:

         
      
      
      
         
      
      
      • Create a client and use NetworkCredential to pass your credentials:

               ServiceReference.MyClient proxy = new ServiceReference.MyClient();
               proxy.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("MACHINENAME\\USERACCOUNT", "passwrd");
               proxy.YourServiceOperation();
        

    There are other ways to set username & password indivdually but it didn't work in .Net 4.0. USERACCOUNT is a domain account or LDAP to which your WCF host computer is joined to. If server isnt joined to a domain then create an account locally by running "lusrmgr.msc"

提交回复
热议问题