none
Operation-Level Authentication in WCF RRS feed

  • Question

  • Hi, I am using a WCF service with UserName authentication and a custom membership provider for authorisation. I want to pass in a parameter to that instance of the web service before I set the username and password, but obviously this fails because I haven't set the user credentials yet! Is there any way of setting attributes on a method/operation in the contract so that it doesn't need credentials to call? Can anyone think of another way to do it?!

    My post is similar to this Method Level Authentication Post, but the suggested solution there is to create a new endpoint and call a method from that instance and perform the function there - this isn't quite what I want in this scenario, as I want to initialise a variable in the current instance I use for authentication. 

    I hope this makes sense, thanks in advance.
    Monday, December 1, 2008 11:53 AM

Answers

  • Hi,

    Why don't you send Project\Username as username in the credentials (i.e, 123Engineering\Foo) ?. It would have the sintax of domain\username, so you can configure later a custom Membership provider that knows how to parse that username and call to the appropiate database membership provider.

    Regards,
    Pablo.
    Pablo Cibraro - http://weblogs.asp.net/cibrax
    • Marked as answer by Marco Zhou Friday, December 12, 2008 6:08 AM
    Monday, December 8, 2008 11:44 AM

All replies

  • ->  this isn't quite what I want in this scenario, as I want to initialise a variable in the current instance I use for authentication.

    I am not clear why opening another end point with credential type set to  "None" or "Anonymous" doesn't help here? when you say you need to initialize a variable, what type of variable you want to initialize, and how that is related to the authentication logic you want to perform?

    Thanks

    Another Paradigm Shift
    http://shevaspace.blogspot.com
    Thursday, December 4, 2008 5:17 AM
  • I know, I have a really bad way of explaining things.

    Our company's rubbish system means that we have a separate table for each set of username / passwords for each client with a prefix of a project code on the name. Which means that for a company called 123Engineering, the username/password table would be called 123USERS, with all the user credentials in that table. For another company called 567Engineering, we would have a table called 567USERS with THEIR set of username/password credentials, and so on.

    So, what I need to do is send the project code (123, 567 etc.) before I pass in the credentials so I know which table I'm using for authentication in the membership provider! The immediate way I thought of doing this was to have a method with no required authentication, but I'm happy to accept any alternatives.

    Thanks again, and sorry for the explanations!

    M.
    Monday, December 8, 2008 10:46 AM
  • Hi,

    Why don't you send Project\Username as username in the credentials (i.e, 123Engineering\Foo) ?. It would have the sintax of domain\username, so you can configure later a custom Membership provider that knows how to parse that username and call to the appropiate database membership provider.

    Regards,
    Pablo.
    Pablo Cibraro - http://weblogs.asp.net/cibrax
    • Marked as answer by Marco Zhou Friday, December 12, 2008 6:08 AM
    Monday, December 8, 2008 11:44 AM