Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. WCF Windows Service with ASP.net Application authentication problem...

WCF Windows Service with ASP.net Application authentication problem...

Scheduled Pinned Locked Moved C#
csharpquestionasp-netwcfsysadmin
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JD86
    wrote on last edited by
    #1

    I'm trying to get a ASP.net application to talk to a WCF Windows Service. Both are on the same internal network and belong to the same domain, but are on different machines. When connecting I see on the tracing log on my WCF Windows Service:

    System.IdentityModel.Tokens.SecurityTokenValidationException: The service does not allow you to log on anonymously.

    From what I understand WCF will use windows authentication by default. How do I pass credentials to the WCF service? This is how i'm connecting from the ASP.net client:

        public static string Authenticate(string username, string password)
        {
            DomainControllerClient dc = null;
    
            try
            {
                dc = new DomainControllerClient();
                dc.Open();
    
                bool success = dc.Authenticate(username, password);
                if (success)
                    return "OK";
                else
                    return "FAIL";
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            finally
            {
                if (dc.State == CommunicationState.Opened)
                    dc.Close();
                else if (dc.State == CommunicationState.Faulted)
                    dc.Abort();
    
                dc = null;
            }
        }
    

    ** BTW I'm using netTcpBinding

    J 1 Reply Last reply
    0
    • J JD86

      I'm trying to get a ASP.net application to talk to a WCF Windows Service. Both are on the same internal network and belong to the same domain, but are on different machines. When connecting I see on the tracing log on my WCF Windows Service:

      System.IdentityModel.Tokens.SecurityTokenValidationException: The service does not allow you to log on anonymously.

      From what I understand WCF will use windows authentication by default. How do I pass credentials to the WCF service? This is how i'm connecting from the ASP.net client:

          public static string Authenticate(string username, string password)
          {
              DomainControllerClient dc = null;
      
              try
              {
                  dc = new DomainControllerClient();
                  dc.Open();
      
                  bool success = dc.Authenticate(username, password);
                  if (success)
                      return "OK";
                  else
                      return "FAIL";
              }
              catch (Exception ex)
              {
                  return ex.ToString();
              }
              finally
              {
                  if (dc.State == CommunicationState.Opened)
                      dc.Close();
                  else if (dc.State == CommunicationState.Faulted)
                      dc.Abort();
      
                  dc = null;
              }
          }
      

      ** BTW I'm using netTcpBinding

      J Offline
      J Offline
      JD86
      wrote on last edited by
      #2

      Found an article: Implement Windows authentication and security in WCF Service[^] Would this be the best way? Put the credentials in the web.config appsettings section and use those for each call?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups