V4 Membership Provider & ASP.NET controls Options
warren
Posted: Tuesday, June 24, 2008 4:21:41 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
Hello all, I plan to use this thread for me to ask questions and discuss the new v4 Membership Providers & the ASP.NET Login controls for Umbraco v4.

I am currently playing with the <asp:login> control which I can get to work without a problem.

But the next step for me is to get this working with the umbraco "Public Access" function.
The Public Access section asks for a Member Group that you wish to allow access.

So my question is when using the Membership provider, how do I assign my memberType to part of the memberGroup that will have access to this page?



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Adz
Posted: Wednesday, June 25, 2008 12:01:33 AM

Rank: Aficionado

Joined: 6/5/2008
Posts: 147
Location: United Kingdom
Hi Warren,

I expect I am missing the point.

On the site I am working on you have to assign the Member Group to a member, and not to a Member Type.

So whenever you create a new Member, you assign the group(s) to the Member.

It would be nice if there was a way to assign groups to a Member Type though! Was that functionality available in v3?

I am using the Umbraco Backend Membership functionality - not the .NET User Wizard.

Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
warren
Posted: Wednesday, June 25, 2008 9:23:48 AM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
Sorry Adz that was what I meant, I used the wrong terminology.

Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Adz
Posted: Thursday, June 26, 2008 11:57:57 AM

Rank: Aficionado

Joined: 6/5/2008
Posts: 147
Location: United Kingdom
So here are the steps which I have followed:

1) Create a member group in the Membership section of Umbraco (e.g. "RegisteredMember")
2) Create a member type in the Membership section of Umbraco (e.g. "MyMemberType")
3) Edit web.config so that the defaultMemberTypeAlias="MyMemberType"
4) In the content section, right click on a node and set "Public Access" to allow the "RegisteredMember" group
5) Create a member in the Membership section, of type "MyMemberType"
6) Create the password
7) Assign the new member to the "RegisteredMember" group

You should now have a member who can login to the site.

For the benefit of other readers of this thread:-

See also http://en.wikibooks.org/wiki/Umbraco/Samples_and_Articles/Protecting_Documents
and http://hartvig.com/screencasts/members.htm

The next problem is, if you allow members to register themselves (e.g. like on a Forum) - how do they automatically get assigned the "RegisteredMember" group ...?



Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
warren
Posted: Thursday, June 26, 2008 12:12:30 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
I have the answer to that Adam!

Paul Sterling come to the rescue with that
Quote:
umbraco/member group = membership/role - I use :: Roles.AddUserToRole(username, "rolename")


VB code version
Code:

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
      Roles.AddUserToRole(CreateUserWizard1.UserName, "RegisteredMember")
End Sub


I have yet to test this but it should work without a problem.

Warren


Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Dirk
Posted: Thursday, June 26, 2008 12:13:47 PM

Rank: Umbracoholic

Joined: 9/27/2007
Posts: 1,022
Location: Belgium
Shouldn't be too hard using an action handler, which is firing during a save action. Haven't really done that in v4, but don't think it has changed since v3x

Hope that helps.
/Dirk


level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
Ig_p118
Posted: Monday, June 30, 2008 12:51:07 PM
Rank: Fanatic

Joined: 7/21/2006
Posts: 274
Location: Salerno - Italy
Question:

Is v4 beta 1 enough stable for production?
If no, How Can I use ASP.NET membership model or standard Umbraco membership model into 3.0.5?
How Can I use Umbraco membership model for a community site or ecommerce site ( register,login,update login information,private zone, ecc ) via .NET code or XSLT?
Brick wall
Many Thanks...

Red Consulting s.a.s - Umbraco from v1.0
Ig_p118
Posted: Thursday, July 03, 2008 9:08:15 AM
Rank: Fanatic

Joined: 7/21/2006
Posts: 274
Location: Salerno - Italy
warren wrote:
I have the answer to that Adam!

Paul Sterling come to the rescue with that
Quote:
umbraco/member group = membership/role - I use :: Roles.AddUserToRole(username, "rolename")


VB code version
Code:

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
      Roles.AddUserToRole(CreateUserWizard1.UserName, "RegisteredMember")
End Sub


I have yet to test this but it should work without a problem.

Warren


This is for .NET Membership and not for Umbraco 3.0.5

Red Consulting s.a.s - Umbraco from v1.0
warren
Posted: Thursday, July 03, 2008 9:23:47 AM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
Hi Ig_p118 yes I know this more of an ASP.NET question however it will be a common question for people wanting to use the ASP.NET deafult membership controls.

I checked the code the other day and of course it worked fine without any problems, when I get some time again I will continue my research with these controls.

//Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
warren
Posted: Thursday, July 03, 2008 6:26:45 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
I have tried to use in XSLT the GetCurrentMember() XSLT extension method and it is not working, please anyone who is doing similar membership work in V4 please vote this item on CodePlex

http://www.codeplex.com/WorkItem/View.aspx?ProjectName=umbraco&WorkItemId=17169

Thanks,
Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
warren
Posted: Thursday, July 03, 2008 7:29:26 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
Continuing my little adventure with this...

I am creating a .NET usercontrol that logs out the user

Code:
protected void logOutLink_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        FormsAuthentication.RedirectToLoginPage();
    }


Additionally I had to change the web config for the login URL in my website

Code:
<authentication mode="Forms">
      <forms name="yourAuthCookie" loginUrl="/login.aspx" protection="All" path="/" />
</authentication>


The logout code works fine to an extent it redirects to
http://localhost/login.aspx?ReturnUrl=%2fdefault.aspx%3fumbPage%3d%2fmembers.aspx%26

Where it automatically adds the ReturnUrl querystring in doing so I get the default 404 error.

Quote:

No umbraco document matches the url 'http://localhost/default.aspx?umbPage=l=/default.aspx?umbPage=/members.aspx&&'

umbraco tried this to match it using this xpath query'/root/node/node [@urlName = "l="]/node [@urlName = "default?umbpage="]/node [@urlName = "members&"]')


As soon as i remove the ReturnUrl querystring it works perfectly. So does anyone know how I could use the default .NET way of doing this.

Before you all mention I know i could do a simple redirect to the page in the code - but surely it is best to use standards?

If its a real b**ch to do the RedirectToLoginPage with Umbraco then i'll use a simple redirect.

//Warren





Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
psterling@homax
Posted: Thursday, July 03, 2008 8:57:06 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 217
Location: Bellingham
Warren -

Check out this thread (same issue).

Unfortunately, the default RedirectToLoginPage() method does not play nicely with Umbraco membership and Url Rewriting.

I haven't looked, but if it's not already there I'll log this for v4 at CodePlex.

-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
psterling@homax
Posted: Thursday, July 03, 2008 10:06:00 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 217
Location: Bellingham
Just updating back here for reference.

Here's the CodePlex issue for v4.

http://www.codeplex.com/umbraco/WorkItem/View.aspx?WorkItemId=17252

-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
Adz
Posted: Friday, July 04, 2008 11:10:43 AM

Rank: Aficionado

Joined: 6/5/2008
Posts: 147
Location: United Kingdom
On our websites we have abondoned the standard .NET controls - instead, Paul (Symes) has developed customised controls.
The primary reason for this is that the standard .NET controls have to be placed in side a <form runat="server"> tag. If you have other .NET controls elsewhere on the page this can be difficult to manage.

I also identified another membership bug in V4 - the "HasAccess" function does not work. This means that, for example, XSLTSearch is not able to search sites which use Membership. Nor will any other XSLT macro or .NET control which makes use of the function.

We have patched this internally and supplied the patch to the core Umbraco team, again see codeplex for details:

http://www.codeplex.com/WorkItem/View.aspx?ProjectName=umbraco&WorkItemId=17169

Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
warren
Posted: Friday, July 04, 2008 11:44:40 AM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
@Adz I am pretty sure I got HasAccess() to return true the other day, but I will check a bit later today just to make sure.

Also Im not sure I fully understand the <form runat="server"> problem?

//Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
warren
Posted: Friday, July 04, 2008 1:21:34 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
@Paul I am not sure if this is a related problem to the logout code.

When visiting a protected page, my login page with the login control loads. I login and get redirected to the protected page fine however I would like to try and avoid the umbPage querystring URL.

So
http://localhost/default.aspx?umbPage=/members.aspx&

would become
http://localhost/members.aspx

Is this possible to do?

//Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Adz
Posted: Friday, July 04, 2008 3:01:43 PM

Rank: Aficionado

Joined: 6/5/2008
Posts: 147
Location: United Kingdom
warren wrote:
@Adz I am pretty sure I got HasAccess() to return true the other day, but I will check a bit later today just to make sure.

Also Im not sure I fully understand the <form runat="server"> problem?

//Warren



I had to debug and fix the HasAccess function - and submitted the solution to CodePlex.
Basically it was using the old Membership code, not the new .NET setup - and was looking for session/cookie information which no longer exists.
I have a patched version running now which solves the problem.

I think we both have experienced the runat=server issue now! .NET only allows you to have one server-side form on the page.

So, if you use the .NET Login control, then the XSLTSearch (standard HTML form) then try to put another .NET control on the page - you get an error.

Adam Perry (blog, twitter), developing Umbraco based websites and applications for ConnectDigital.
psterling@homax
Posted: Monday, July 07, 2008 6:45:54 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 217
Location: Bellingham
@Warren

warren wrote:

So
http://localhost/default.aspx?umbPage=/members.aspx&

would become
http://localhost/members.aspx

Is this possible to do?


I think this is possible. Without actually diving into the code I assume we'd need to specify the redirectTo Url in an umbraco friendly format and let Url Rewriting take care of loading the correct page. So, something like this:

Code:
...if authentication is successful...
......set authentication ticket explicitly (as opposed to calling RedirectFromLoginPage()...
......get [i]redirectTo[/i] Url from query string (?ReturnUrl=member.aspx)...
......do the redirect specifying the umbraco Url  (http://<yoursite>/member.aspx)...


Is this too obvious? Maybe I'm not grasping the issue, but based on my understanding this is one approach.

-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
warren
Posted: Monday, July 07, 2008 7:44:22 PM

Rank: Addict

Joined: 7/19/2006
Posts: 783
Location: Leigh-on-Sea, Essex, UK
Hiya Paul, thanks for the reply.
I was hoping to solve this without going into the codeBehind for the Login control (as I want to keep the controls as simple as possible).

I'm not sure I fully understand what you mean, if you don't mind dropping me an email on this rather than discussing the problem on here. Oncel solved I will post the solution here.

Thanks,
Warren



Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Skiltz
Posted: Tuesday, July 15, 2008 9:55:47 AM

Rank: Devotee

Joined: 12/6/2007
Posts: 61
I've had a play with the login/logout securing pages etc and all works well! - Has anyone created a editprofile usercontrol?? I know there was one for the member controls for 3.0.5 but I believe this needs to modified some for use with the new provider....or am I wrong??

New Zealand Umbracoee
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.