Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2008

Tip: Looking for answers? Try searching our database.

WCF - Client Credentials (Username/Password) - ASP.NET Membership

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Philip - 06 Mar 2008 06:08 GMT
I am using the ASP.NET Membership provider for username/password
authentication with my WCF service, and this authentication process is
working fine, however I am unable to obtain the authenticated username within
my WCF service.  I need to know the username for database accessing purposes.

I am using the <serviceHostingEnvironment
aspNetCompatibilityEnabled="true"/> in the web.config and
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Required)] attribute on the WCF Service
class.   Upon entry to the WCF Service, System.Web.HttpContext.Current is not
null, however System.Web.HttpContext.Current.User.Identity.Name is zero
length and System.Web.HttpContext.Current.User.Identity.IsAuthenticated ==
false.

Please HELP....how can I access the authenticated username.

I know ASP.NET Membership authentication is working, because I can change
the password in the client credentials to an invalid value, and the WCF
service fails with security exception.

Signature

Philip

Philip - 07 Mar 2008 16:05 GMT
Hello ?....is anyone home ?

Signature

Philip

> I am using the ASP.NET Membership provider for username/password
> authentication with my WCF service, and this authentication process is
[quoted text clipped - 15 lines]
> the password in the client credentials to an invalid value, and the WCF
> service fails with security exception.
John Saunders [MVP] - 07 Mar 2008 21:00 GMT
> Hello ?....is anyone home ?

Philip, I'm "home", I'm just "not all there". ;-)

I'm only just picking up on WCF this past few weeks. Ironically, I just
mentioned your post to my manager last night, as proof that WCF can use the
Membership provider for authentication. I told him that your only problem
was not being able to find the current user, and that I thought you'd have
your answer by now.

Maybe we can help each other out. You may be able to save me a great deal of
time by posting links to documentation or articles you've found on using the
Membership provider with WCF. If you have a small project that reproduces
the problem, that would be great, too.

For my part, I need to be able to show how the Membership provider can work
in WCF, so I would take what you post as a starting point, and research the
problem from there, over the weekend, because I find WCF just _so_ exciting.
Signature

--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Philip - 07 Mar 2008 21:55 GMT
http://msdn2.microsoft.com/en-us/library/ms731049.aspx

http://nayyeri.net/blog/use-asp-net-membership-and-role-providers-in-windows-com
munication-foundation/


Here are a couple of URLs on how to use the ASP.NET Membership Provider
within WCF.

Let me know if you need for me to pull together my WCF project....it is just
rather large.... so I would need to do some copy and paste activity.  Keep in
mind.... the ASP.NET Membership Provider works fine within WCF....however I
am attempting to use the ASP.NETCompatibility attribute to gain access to the
Username....but no such luck.....Username is not visible.  The Http Context
is there....but IsAuthenticated() == False.... and Username == string.empty.

I appreciate your help....this is critical for me....does not do me much
good if the ASP.NET Membership Provider works yet I do not work who the user
is....

Again...thanks.

Philip

Signature

Philip

> > Hello ?....is anyone home ?
>
[quoted text clipped - 14 lines]
> in WCF, so I would take what you post as a starting point, and research the
> problem from there, over the weekend, because I find WCF just _so_ exciting.
Adam.C.Main - 12 Mar 2008 18:17 GMT
Have you tried using System.Threading.Thread.CurrentPrincipal.Identity.Name?  
I'm using membership providers for my WCF service authentication, and that
appears to be working for me.  I need to do more extensive testing, but so
far so good.

-Adam

> http://msdn2.microsoft.com/en-us/library/ms731049.aspx
>
[quoted text clipped - 17 lines]
>
> Philip
Philip - 12 Mar 2008 19:28 GMT
Thank you very much for the info...

I will definitely try this.

Signature

Philip

> Have you tried using System.Threading.Thread.CurrentPrincipal.Identity.Name?  
> I'm using membership providers for my WCF service authentication, and that
[quoted text clipped - 24 lines]
> >
> > Philip
Philip - 12 Mar 2008 20:06 GMT
Adam,

Good news...System.Threading.Thread.CurrentPrincipal.Identity.Name does
properly identify the authenticated Username.  One other
note...System.Threading.Thread.CurrentPrincipal.Identity.Name does not work
when operating in AspNetCompatibility mode....returns zero length Username...
however in my case this is fine...I did not want to operate in
AspNetCompatibility mode anyway.

Thanks for your assistance.

Signature

Philip

> Thank you very much for the info...
>
[quoted text clipped - 28 lines]
> > >
> > > Philip

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.