studio NETSOULS

Applying Web To Your Business

The asp.net membership has the mechanism that it locks out a user's account if he/she tries to authenticate themselves with false password five times, by default, or within 10 minute window. The locked user can then not login.

In the MembershipUser class there is a public method UnlockUser() that you can call for any username to unlock the user, this will reset their LastLockOutdate field etc and allow the users to login using the same password.

   1: MembershipUser user = Membership.GetUser(username);
   2: user.UnlockUser();

I just came across this problem and found this  solution and thought it would be a great help to others also.
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

At first glance, it should be easy to inject a javascript, but it took a little bit of digging around to figure out the resolution, the key is to use ScriptManager.

   1: <asp:UpdatePanel ID="myUpdatePanel" UpdateMode="Conditional" runat="server">
   2:    <Triggers>
   3:       <asp:AsyncPostBackTrigger ControlID="btnClick" EventName="Click" />
   4:    </Triggers>
   5:    <ContentTemplate>
   6:        <asp:ImageButton 
   7:           ID="btnClick" 
   8:           ImageUrl="ClickMe.png" 
   9:           runat="server"
  10:           CausesValidation="false" 
  11:           OnClick="btnClickEvent"
  12:           ToolTip="Click Me" 
  13:           AlternateText="Click me!" />
  14:    </ContentTemplate>
  15: </asp:UpdatePanel>

We wanted to dynamically inject some JavaScript code. If my ScriptManager control has EnablePartialRendering set to true, it's a simple matter of registering the script. What i didn't realize earlier was that you don't need to the use the current page or current event, you need to call the static method on the ScriptManager class.

   1: protected void btnClickEvent(object sender, ImageClickEventArgs e)
   2: {
   3:    btnClick.Text = "I was clicked."
   4:    btnClick.Disabled = true;
   5:    ScriptManager.RegisterClientScriptBlock(myUpdatePanel, typeof(UpdatePanel),myUpdatePanel.ClientID, "alert('It worked!');",true);            
   6: }

That's it! Use the ScriptManager class, point it to the instance of your update panel, pass it a unique key and then the JavaScript you want, and it will be executed once the update panel is done rendering.

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

I would like to set the a property value on a user control. It sounds easy enough. First, I would like to create a web control then I would like to access one of its properties "HasAccess" and set the value to "true".

In this example we are assuming that the web control is been called from a master page and the property that needs to be set is from a web page. In the web page we need to first find the user control and then set its property.

   1: if (Master != null)
   2: {
   3:     Control ctlMyControl = Master.FindControl("ctlMyControl") as Control;
   4:     if (ctlMyControl != null)
   5:     {
   6:         Type ucType = null;
   7:         ucType = ctlMyControl .GetType();
   8:  
   9:         PropertyInfo hasAccess = ucType.GetProperty("HasAccess");
  10:  
  11:         // Only set the first control as each on page will pass through code. 
  12:         if (hasAccess.GetValue(ctlMyControl , null) == null)
  13:             hasAccess.SetValue(ctlMyControl , True, null);
  14:     }
  15: }
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

When you restore a Microsoft SQL Server database on a different machine, you cannot access the database until you fix the permissions.

The problem is that the user in the database is an "orphan". This means that there is no login id or password associated with the user. This is true even if there is a login id that matches the user, since there is a GUID (called a SID in Microsoft-speak) that has to match as well.

This used to be a pain to fix, but currently (SQL Server 2000, SP3 and higher) there is a stored procedure that does.

You should execute the stored procedure as a database admin, with the restored database selected

--First, make sure that this is the problem. This will lists the orphaned users:
EXEC sp_change_users_login 'Report' 
 
--If you already have a login id and password for this user, fix it by doing: 
EXEC sp_change_users_login 'Auto_Fix', 'user' 
 
--If you want to create a new login id and password for this user, fix it by doing: 
EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password' 
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

About Us

studio NETSOULS is a complete IT services company, offering strategy, design, development and implementation of the total solution for your web and IT initiatives. The solutions we provide, enables businesses to leverage leading edge technology to gain sustainable competitive advantages in today's marketplace.

We specialize in designing, developing and deploying the next generation of IT solutions including e-business solutions Read more...

Tags

This will be shown to users with no Flash or Javascript.

Contact Us

My status

Quote of the Day

"Do you see a man wise in his own eyes? There is more hope for a fool than for him."

- Proverbs 26:12

NutritionVista

www.NutritionVista.com

Archives


Advertisements


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Log in