How to get of last created user using CreateUserWizard?

Discussion in 'ASP .Net Security' started by Rodusa, Jul 22, 2005.

  1. Rodusa

    Rodusa Guest

    Could someone please recommend the best way and how to obtain the last
    inserted userid of users (security) table using the Button click event
    of CreateUserWizard? In classic Asp and Asp.net 1.x I used the
    @@identity to get the last inserted record of my custom table, but now
    I don't know how Asp.net does that. I would like to understand how it
    works behind the scenes, the sequence of processing. I saw that there
    is an event called createuser in CreateUserWizard control which is
    fired after the user is created. Is this the best place to implement
    the get the last userid? In addition, is it safe? Does it garantee
    that no other user will get that userid and that locks that value to
    used in this same event?

    Thanks
    Rod
     
    Rodusa, Jul 22, 2005
    #1
    1. Advertising

  2. Rodusa

    Brock Allen Guest

    The CreateUserWizard fires a UserCreated event. Once that's fired, you can
    access the Username and Password properties of the control. With the Username
    if you need to you should be able to call into the Membership class to get
    anything else you need.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Could someone please recommend the best way and how to obtain the last
    > inserted userid of users (security) table using the Button click event
    > of CreateUserWizard? In classic Asp and Asp.net 1.x I used the
    > @@identity to get the last inserted record of my custom table, but now
    > I don't know how Asp.net does that. I would like to understand how it
    > works behind the scenes, the sequence of processing. I saw that there
    > is an event called createuser in CreateUserWizard control which is
    > fired after the user is created. Is this the best place to implement
    > the get the last userid? In addition, is it safe? Does it garantee
    > that no other user will get that userid and that locks that value to
    > used in this same event?
    >
    > Thanks Rod
    >
     
    Brock Allen, Jul 22, 2005
    #2
    1. Advertising

  3. Rodusa

    Rodusa Guest

    Re: How to get of last created user using CreateUserWizard?

    Brock, I am new to security in Asp.net 2.0. Can you provide some
    example of how to get the last created userid using the
    membershipclass?

    Thank you

    Rod
    Brock Allen wrote:
    > The CreateUserWizard fires a UserCreated event. Once that's fired, you can
    > access the Username and Password properties of the control. With the Username
    > if you need to you should be able to call into the Membership class to get
    > anything else you need.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > Could someone please recommend the best way and how to obtain the last
    > > inserted userid of users (security) table using the Button click event
    > > of CreateUserWizard? In classic Asp and Asp.net 1.x I used the
    > > @@identity to get the last inserted record of my custom table, but now
    > > I don't know how Asp.net does that. I would like to understand how it
    > > works behind the scenes, the sequence of processing. I saw that there
    > > is an event called createuser in CreateUserWizard control which is
    > > fired after the user is created. Is this the best place to implement
    > > the get the last userid? In addition, is it safe? Does it garantee
    > > that no other user will get that userid and that locks that value to
    > > used in this same event?
    > >
    > > Thanks Rod
    > >
     
    Rodusa, Jul 25, 2005
    #3
  4. Rodusa

    Brock Allen Guest

    Re: How to get of last created user using CreateUserWizard?

    <asp:CreateUserWizard runat=server ID=_createUser OnCreatedUser="_createUser_CreatedUser"></asp:CreateUserWizard>

    <script runat="server">
    protected void _createUser_CreatedUser(object sender, EventArgs e)
    {
    string name = _createUser.UserName;
    MembershipUser user = Membership.GetUser(name);
    object key = user.ProviderUserKey;
    }
    </script>

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Brock, I am new to security in Asp.net 2.0. Can you provide some
    > example of how to get the last created userid using the
    > membershipclass?
    >
    > Thank you
    >
    > Rod
    > Brock Allen wrote:
    >> The CreateUserWizard fires a UserCreated event. Once that's fired,
    >> you can access the Username and Password properties of the control.
    >> With the Username if you need to you should be able to call into the
    >> Membership class to get anything else you need.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> Could someone please recommend the best way and how to obtain the
    >>> last inserted userid of users (security) table using the Button
    >>> click event of CreateUserWizard? In classic Asp and Asp.net 1.x I
    >>> used the @@identity to get the last inserted record of my custom
    >>> table, but now I don't know how Asp.net does that. I would like to
    >>> understand how it works behind the scenes, the sequence of
    >>> processing. I saw that there is an event called createuser in
    >>> CreateUserWizard control which is fired after the user is created.
    >>> Is this the best place to implement the get the last userid? In
    >>> addition, is it safe? Does it garantee that no other user will get
    >>> that userid and that locks that value to used in this same event?
    >>>
    >>> Thanks Rod
    >>>
     
    Brock Allen, Jul 25, 2005
    #4
  5. Rodusa

    Rodusa Guest

    Re: How to get of last created user using CreateUserWizard?

    I see that you assume that the the login name should be unique. Anyhow,
    this is perfect and works great.

    Thanks for your fast response.

    Rod
     
    Rodusa, Jul 25, 2005
    #5
  6. Rodusa

    Brock Allen Guest

    Re: How to get of last created user using CreateUserWizard?

    The login name is unique within the scope of the application. That's the
    Membership model.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I see that you assume that the the login name should be unique.
    > Anyhow, this is perfect and works great.
    >
    > Thanks for your fast response.
    >
    > Rod
    >
     
    Brock Allen, Jul 25, 2005
    #6
  7. Re: How to get of last created user using CreateUserWizard?

    I have one additional question:
    How can I use only email instead using UserID? I try to set
    RequireEmail="False" and use only UserName, but validation always says
    your's email is in wrong format...

    Regards
    Mateusz www.Kierepka.pl ;)

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Mateusz Kierepka, Dec 29, 2005
    #7
  8. Re: How to get of last created user using CreateUserWizard?

    Hi,

    you can set email requirements on the control and the provider - have you
    set both??

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > I have one additional question:
    > How can I use only email instead using UserID? I try to set
    > RequireEmail="False" and use only UserName, but validation always says
    > your's email is in wrong format...
    > Regards
    > Mateusz www.Kierepka.pl ;)
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    Dominick Baier [DevelopMentor], Dec 29, 2005
    #8
    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?UmF2ZW50aG9ybg==?=

    Avoiding the automatic creation of a user in the CreateUserWizard

    =?Utf-8?B?UmF2ZW50aG9ybg==?=, Apr 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,381
    stiven
    Dec 29, 2005
  2. Replies:
    0
    Views:
    366
  3. Adam Right
    Replies:
    2
    Views:
    1,695
  4. Learner
    Replies:
    1
    Views:
    158
    jfkrueger
    Apr 14, 2006
  5. GoCMS
    Replies:
    2
    Views:
    396
    GoCMS
    Jan 14, 2005
Loading...

Share This Page