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 - 04 Mar 2008 14:25 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:04 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.
Tiago Halm - 12 Mar 2008 23:41 GMT
In WCF you can get the authenticated user in one of two ways:
either
  ServiceSecurityContext.Current.WindowsIdentity.*
or
  OperationContext.Current.ServiceSecurityContext.WindowsIdentity.*

Namespace is System.ServiceModel.

Tiago Halm

>I am using the ASP.NET Membership provider for username/password
> authentication with my WCF service, and this authentication process is
[quoted text clipped - 19 lines]
> the password in the client credentials to an invalid value, and the WCF
> service fails with security exception.
Tiago Halm - 12 Mar 2008 23:48 GMT
Ooops, sorry, I missed the custom username/password. I thought it was
Windows auth. Never tried custom username/password with membership, because
on my scenario I used a username token with a custom authorization scheme
built around Parameter Inspectors. I built a custom service/client
credential so I would be able to delegate token on downstream calls and was
able to have it inside ServiceSecurityContext.Current.PrimaryIdentity.

Don't know if it helps.

Tiago Halm

> In WCF you can get the authenticated user in one of two ways:
> either
[quoted text clipped - 30 lines]
>> the password in the client credentials to an invalid value, and the WCF
>> service fails with security exception.
Philip - 13 Mar 2008 01:43 GMT
Thanks....I already have my question answered....I am using
System.Threading.Thread.CurrentPrincipal.Identity.Name

Signature

Philip

> Ooops, sorry, I missed the custom username/password. I thought it was
> Windows auth. Never tried custom username/password with membership, because
[quoted text clipped - 41 lines]
> >> the password in the client credentials to an invalid value, and the WCF
> >> service fails with security exception.
IliaJ - 25 Mar 2008 17:30 GMT
Strange, System.Web.HttpContext.Current.User.Identity.Name works OK for me in
a simple test project.

> Thanks....I already have my question answered....I am using
> System.Threading.Thread.CurrentPrincipal.Identity.Name
Philip - 25 Mar 2008 21:43 GMT
Can you email me your sample app to plippard@sanibellogic.com ?

Presumably....you are using the Membership provider for authentication ?

Thanks

Signature

Philip

> Strange, System.Web.HttpContext.Current.User.Identity.Name works OK for me in
> a simple test project.
>
> > Thanks....I already have my question answered....I am using
> > System.Threading.Thread.CurrentPrincipal.Identity.Name
Philip - 28 Mar 2008 19:36 GMT
I have reviewed your code.....and your code is working because you are
conducting a separate login step via an attended login web web page.

I am attempting to login at WCF service call time...using the WCF
ClientCredentials set of values within the WCF proxy....as illustrated
below...

               ProductsSvc.ProductsSvcClient productsSvcProxy = new
ProductsSvc.ProductsSvcClient();
               productsSvcProxy.ClientCredentials.UserName.UserName =
"JackBenny";
               productsSvcProxy.ClientCredentials.UserName.Password =
"helloworld";

               productsSvcProxy.GetProductListCompleted += new
EventHandler<ProductsSvc.GetProductListCompletedEventArgs>(productsSvc_GetProductListingCompleted);
               productsSvcProxy.GetProductListAsync();

I have to examine the System.Threading.Thread.CurrentPrincipal.Identity
value to obtain the Membership Provider logged-in username.   I can not get
the Username by looking at the compatibility values....as discussed earlier
in my problem description.

Signature

Philip

> Strange, System.Web.HttpContext.Current.User.Identity.Name works OK for me in
> a simple test project.
>
> > Thanks....I already have my question answered....I am using
> > System.Threading.Thread.CurrentPrincipal.Identity.Name

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.