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

From: Brock Allen (ballen_at_NOSPAMdevelop.com)
Date: 07/25/05


Date: Mon, 25 Jul 2005 09:41:51 -0700


<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
>>>


Quantcast