More in this section

Forums / Developing with Sitefinity / Get User data and reactivate account

Get User data and reactivate account

2 posts, 0 answered
  1. marco pessina
    marco pessina avatar
    16 posts
    02 Nov 2009
    15 Dec 2009
    Link to this post


    Could you please tell me how to load user data from a Telerik.DataAccess.AspnetProviders.User object of which I only know the UserName?

    Is there a way to intercept when a user in the login phase is blocked due to too many attempt?

    In the User Administration interface I need to have the possibility to reactivate a user with IsLockedOut = True, how can I do that?


    Thank you

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    15 Dec 2009
    Link to this post
    Hello marco pessina,

     You can use the code below to access the date form the Membership provider

    string name = Telerik.Security.UserManager.GetCurrentUserName();
    MembershipUser user = Membership.GetUser(name);
    string datecreation = user.CreationDate.ToString();
    string email = user.Email;
    bool approved = user.IsApproved;

    As you see, you can use standard ASP.NET class MembershipUser Class to retrieve the needed data.

    In your project web.config you can set the maxInvalidPasswordAttempts and other membership provider properties.

    <membership defaultProvider="Sitefinity" userIsOnlineTimeWindow="15" hashAlgorithmType="">
                    <add name="Sitefinity" connectionStringName="DefaultConnection" type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider, Telerik.DataAccess" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>

    isLockedOut has only get accessor so you cannot set the value to this property. You can use IsApproved instead. You can modify ~/Sitefinity/Admin/CmsAdmin/Users.aspx and ~/Sitefinity/Admin/CmsAdmin/Users.aspx.cs to add your checkbox and set the value


    Membership Info</h3>
                      <fieldset class="userinfo set">
                          <ol class="setIn">
                              <li class="exField">
                                      <dt>Username</dt><dd class="readOnly"><asp:Literal ID="UserName" runat="server"></asp:Literal></dd>
                                      <dd class="example">
                                          The username cannot be changed</dd>
                                  <cc2:FieldLabel ID="lblEmail" runat="server" Text="Email *" TargetID="Email">
                                  <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Email"
                                      ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUser"
                                      Display="Dynamic" CssClass="validMessage"><strong>E-mail cannot be empty!</strong></asp:RequiredFieldValidator>
                                  <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="Email"
                                      Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="\S+@\S+\.\S+"
                                      ValidationGroup="CreateUser" CssClass="validMessage"><strong>The email format is invalid!</strong></asp:RegularExpressionValidator>
                              <li class="newPass">
                                  <asp:LinkButton ID="passwordRecoveryButton" runat="server" Text="Reset password" OnClick="passwordRecoveryButton_Click" Tooltip="Click to automatically create a new password for this user." OnClientClick="return confirm('Are you sure you want to change the password for this user?');"/>
                               <li class="newPass">
                               <asp:CheckBox runat="server" ID="isLockedCheckBox" />

    protected override void OnPreRender(EventArgs e)
            Telerik.Security.WebControls.ManageUsers.EditContainer editContainer = manageUsers.GetCurrentContainer() as Telerik.Security.WebControls.ManageUsers.EditContainer;
            if (editContainer != null)
                string uname = manageUsers.UserName;
                MembershipUser user = Membership.GetUser(uname);
                CheckBox isLockedCheckBox = (CheckBox)editContainer.FindControl("isLockedCheckBox");
                if (isLockedCheckBox != null)
                    if (user.IsApproved)
                         isLockedCheckBox.Checked = false;
                        isLockedCheckBox.Checked = true;

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered