Membership/roles help

Discussion in 'ASP .Net Security' started by John, Aug 28, 2006.

  1. John

    John Guest

    Hi

    I have looked in help but am not clear how to do the following in vb.net
    code.

    1. Check if a user belongs to a specific role.

    2. Change user's password. Is it possible to do it without knowing the
    old/existing password?

    Would appreciate if someone could give me some pointers.

    Thanks

    Regards
     
    John, Aug 28, 2006
    #1
    1. Advertising

  2. Hi John,

    > 1. Check if a user belongs to a specific role.


    Label1.Text = "Is JackieReeve an Elite Member?:" &
    Roles.IsUserInRole("JackieReeve", "EliteMember").ToString

    http://msdn2.microsoft.com/en-us/library/system.web.security.roles.isuserinrole.aspx

    > 2. Change user's password. Is it possible to do it without knowing the
    > old/existing password?


    Label2.Text = mbrCurrentMember.ResetPassword("Beatles")

    http://msdn2.microsoft.com/en-us/library/d94bdzz2.aspx

    Full code below.

    Let us know if this helps?

    Ken
    Microsoft MVP [ASP.NET]

    <%@ Page Language="VB" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    Protected Sub Page_Load _
    (ByVal sender As Object, ByVal e As System.EventArgs)
    Dim mbrCurrentMember As System.Web.Security.MembershipUser
    mbrCurrentMember = Membership.GetUser("JackieReeve", True)
    Label1.Text = "Is JackieReeve an Elite Member?:" & _
    Roles.IsUserInRole("JackieReeve", "EliteMember").ToString
    If Membership.EnablePasswordReset = True Then
    Label2.Text = mbrCurrentMember.ResetPassword("Beatles")
    Else
    Label2.Text = "Password reset not allowed."
    End If
    End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Membership password reset</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:label id="Label1" runat="server" font-bold="True"
    font-size="X-Large" text="Updating Members"></asp:label><br />
    <br />
    <asp:label id="Label2" runat="server"
    font-size="X-Large"></asp:label><br />
    <br />
    </div>
    </form>
    </body>
    </html>



    "John" <> wrote in message
    news:...
    > Hi
    >
    > I have looked in help but am not clear how to do the following in vb.net
    > code.
    >


    >


    >
    > Would appreciate if someone could give me some pointers.
    >
    > Thanks
    >
    > Regards
    >
    >
     
    Ken Cox [Microsoft MVP], Aug 28, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bGFuZW0=?=
    Replies:
    0
    Views:
    747
    =?Utf-8?B?bGFuZW0=?=
    Oct 21, 2005
  2. John

    Membership roles question

    John, Dec 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    350
    Joshua Flanagan
    Dec 19, 2005
  3. John

    Membership/roles help

    John, Aug 28, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    Ken Cox [Microsoft MVP]
    Aug 28, 2006
  4. Jéjé
    Replies:
    0
    Views:
    260
    Jéjé
    Sep 27, 2005
  5. dw
    Replies:
    5
    Views:
    224
Loading...

Share This Page