ASP.NET Login by username or email

13. June 2011 19:21

Something that isn't support by default in asp.net is the ability to have end users login using either their username or their email address. Though it is somewhat easy to add this support using this little trick to override the normal login procedure on the login control.

 

To get started we will need our aspx page with a login control as follows.

 

<asp:Login runat="server" ID="Login2" DisplayRememberMe="false" 
    DestinationPageUrl="/Users/Default.aspx" onloggingin="Login2_LoggingIn" >
</asp:Login>

 

We can then override the default action in the event handler if we cannot find the current user trying to login and the username contains an '@' symbol.

 

 

public partial class Login : AppPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Login2_LoggingIn(object sender, LoginCancelEventArgs e)
    {
        if (Login2.UserName.Contains("@") && Membership.GetUser(Login2.UserName) == null)
        {
            string Username = Membership.GetUserNameByEmail(Login2.UserName);
            if (Username == null)
                return;

            if (Membership.ValidateUser(Username, Login2.Password) == true)
            {
                FormsAuthentication.SetAuthCookie(Username, false);
                FormsAuthentication.RedirectFromLoginPage(Username, false);
                e.Cancel = true;
            }
        }
    }
}

 

Note: if you are going to use the above you will need to make sure that your configured provider has a unique set of email addresses per user.

E-mail Kick it! DZone it! del.icio.us Permalink


Cisco + Virgin Cable

11. June 2011 10:49

 

I seem to keep running into a problem with a cisco router (a cisco 877) with a virgin media connection. It would appear that part of virgin's network tends to break. I don't know the exact cause but from how I understand it. It is a fault with virgin somehow and some type of compatibility issue with cisco routers.

 

The problem for me tends to trigger when virgin has an issue inside their network or for some reason I have to disable the internet connection. When I bring the connection back up the cisco router can never successfully get an ip address by dhcp again. Until of course virgin is contacted and something is reset at their end. It will however allocate an ip address to a computer if you plug it directly into the virgin connection.

 

Here is how I was debugging the issue. To start with put your cisco terminl connection into monitor mode and debug dhcp (after you become an enabled user of course). Like this

 

Cisco#terminal monitor
Cisco#debug dhcp

 

This will cause you to see output like the following.

 

Jun  6 08:51:39.998: DHCP: deleting entry 83D002B8 0.0.0.0 from list
Jun  6 08:52:09.437: DHCP: Try 15 to acquire address for Vlan2
Jun  6 08:52:09.441: DHCP: allocate request
Jun  6 08:52:09.445: DHCP: new entry. add to queue, interface Vlan2
Jun  6 08:52:09.445: DHCP: SDiscover attempt # 1 for entry:
Jun  6 08:52:09.445: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:52:09.445: DHCP: SDiscover 290 bytes
Jun  6 08:52:09.445:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:52:13.006: DHCP: SDiscover attempt # 2 for entry:
Jun  6 08:52:13.006: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:52:13.006: DHCP: SDiscover 290 bytes
Jun  6 08:52:13.006:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:52:17.006: DHCP: SDiscover attempt # 3 for entry:
Jun  6 08:52:17.006: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:52:17.006: DHCP: SDiscover 290 bytes
Jun  6 08:52:17.006:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:52:28.568: DHCP: Received a BOOTREP pkt Not for us..:  xid: 0x3E466ABF%Unknown DHCP problem.. No allocation possible
Jun  6 08:52:29.924: DHCP: Waiting for 60 seconds on interface Vlan2

 

 

Unfortunatly the information is not very forthcoming with anything that matters. Since virgin is not actually replying to any dhcp requests with anything! So the next step to try is to reboot the cable modem etc... Of course it will just keep repeating the same output as above and virgin will continue to ignore any dhcp requests for some reason.

 

The next part of this is to phone virgin. Tell them specificly that the router is not allocating an address. They will then head off do some checks make sure they can talk to the cable modem directly and quitly reset something. Of course on the next attempt you can then expect some sort of success.

 

 

Jun  6 08:57:31.489: DHCP: Try 19 to acquire address for Vlan2
Jun  6 08:57:31.493: DHCP: allocate request
Jun  6 08:57:31.497: DHCP: new entry. add to queue, interface Vlan2
Jun  6 08:57:31.497: DHCP: SDiscover attempt # 1 for entry:
Jun  6 08:57:31.497: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:57:31.497: DHCP: SDiscover 290 bytes
Jun  6 08:57:31.497:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:57:35.106: DHCP: SDiscover attempt # 2 for entry:
Jun  6 08:57:35.106: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:57:35.106: DHCP: SDiscover 290 bytes
Jun  6 08:57:35.106:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:57:39.106: DHCP: SDiscover attempt # 3 for entry:
Jun  6 08:57:39.106: DHCP: SDiscover: sending 290 byte length DHCP packet
Jun  6 08:57:39.106: DHCP: SDiscover 290 bytes
Jun  6 08:57:39.106:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:57:39.154: DHCP: Received a BOOTREP pkt
Jun  6 08:57:39.154: DHCP: offer received from 62.31.64.115
Jun  6 08:57:39.154: DHCP: SRequest attempt # 1 for entry:
Jun  6 08:57:39.154: DHCP: SRequest- Server ID option: 62.31.64.115
Jun  6 08:57:39.154: DHCP: SRequest- Requested IP addr option: x.x.x.x
Jun  6 08:57:39.154: DHCP: SRequest placed lease len option: 603658
Jun  6 08:57:39.154: DHCP: SRequest: 308 bytes
Jun  6 08:57:39.154: DHCP: SRequest: 308 bytes
Jun  6 08:57:39.154:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:57:42.110: DHCP: SRequest attempt # 2 for entry:
Jun  6 08:57:42.110: DHCP: SRequest- Server ID option: 62.31.64.115
Jun  6 08:57:42.110: DHCP: SRequest- Requested IP addr option: x.x.x.x
Jun  6 08:57:42.110: DHCP: SRequest placed lease len option: 603658
Jun  6 08:57:42.110: DHCP: SRequest: 308 bytes
Jun  6 08:57:42.110: DHCP: SRequest: 308 bytes
Jun  6 08:57:42.110:             B'cast on Vlan2 interface from 0.0.0.0
Jun  6 08:57:42.347: DHCP: Received a BOOTREP pkt
Jun  6 08:57:46.347: DHCP Client Pooling: ***Allocated IP address: x.x.x.x
Jun  6 08:57:46.351: Allocated IP address = x.x.x.x  255.255.255.240

 

 

Finally it gets an ip address. The reason why I suspect this is a problem inside the virgin network is simple. Evertime I have to take the connection offline I can do it by a shutdown of the interface (the easy method) or by rebooting the cisco or some such. This problem occurs in exactly the same way. However the following at the site end of things never changes.

 

  • The cisco will still manage to get an ip address without being restarted.
  • The cisco config has not changed in any way.

 

To make matters worse. Virgin are not capable of allocating a static ip address to the connection. their definition of static is still allocated by dhcp. So there is no way around this problem.

 

I guess its just one of thoose things that will never be fixed by virgin media. I think this is a virgin media issue. What do you think?

E-mail Kick it! DZone it! del.icio.us Permalink


Internet Connection Pricing

8. June 2011 18:26

 

Coming fromt he UK I have always been a little annoyed about the way broadband is sold to end users. Typically the internet providers tend to attempt to sell their services as unlimited and then have a limit in the small print. Personally I think this is grossly unfair and should not be permitted to continue. I actually think the speed the internet providers is also grossly mis leading along with there connections. Since the more modern connections are now performing at very decent speeds of up to 24 mbits / sec. I have decided to have a look at the figures just to see exactly what the internet providers actually offer in terms of usage.

 

When I talk about usage I am actually talking about thoughput. Lets face it once you get speeds faster than 5mbits a second you can stream videos from youtube / iplayer and anything else. So lets look at some providers on the bases of how much you can stream and the value for money you are really getting.

 

I am going to start with plusnet. I used to use them when adsl first arrived inside the UK. Connections were 0.5mbit and it was a real step up from modem speeds at the time. so I decided to look at their top end package of what they could offer me. Though I would point out that they are more honest than most and tell you directly what the limits on the connections are and don't attempt to hide it in the small print. Looking at their website I can figure out the following on their up to 20mbit connection

 

  • Limit - 60GBytes
  • Cost - £11.49
  • Cost / GByte - £0.19
  • Maximum Usage @ 20MBit - 13 Minutes / Day

 

Now lets look at a massive provider inside the UK called BT. I have used connections from BT in the past and a lot of small companies have used them. I have found their technical support (if you could call it that) to be dreadfull with long wait times. Long response times. Long fix times (eg > 1 Week). Not only that but when you look at their largest package they offer an unlimited service. At first this always seems great. However they apply a fair usage policy to their connection at 100Gb. Though their 40Mbit FTTC service looks great (at first glance). This is what I think of them after some calculations.

 

  • Limit - 100GBytes
  • Cost - £28
  • Cost / GByte - £0.28
  • Maximum Usage @ 40 MBit - 11 Minutes / Day

 

So already you can see a pattern. First they are actually more expensive than plusnet. What I find most shocking about this unlimited service is that they consider maximum bandwidth usage of 11minutes / day "fair usage".

 

Now lets look at a smaller provider that I am currently using called BEThere. They are actually the longest provider I have been with which has not applied a "fair usage" policy or I have become so frustrated with. They do have a hidden fair usage policy on their "unlimited" service but I have not been able to find any information to why it was applied. I have seen their connections regularly support downloads of greater than 200GB / Month usage so I for the calculations I am going to put in a guess at 300GB or so. Though I have heard other people who are closer to 300-400GB in usage and still don't have problems. I would also add any support problems have always been corrected within 24-48. Normally within the first 2-4 hours of them occuring.

 

  • Limit - Mayby 300GB?
  • Cost - £22 (I think its up to £27 now)
  • Cost / GBytes - £0.07
  • Maximum Usage @ 24 Mbits - 56 Minutes / Day

 

So there you have it. A completly different way to look at picking an internet provider. I think the reasons for the cost differences are very obvious as well. Plusnet, BT always seem to offer additional services. BEThere don't offer additional services other than an outbound email relay. They provide an internet connection and almost nothing else. So it would appear the company that offers less actually offers *a lot* more.

E-mail Kick it! DZone it! del.icio.us Permalink


Scams - The WOW scam

8. June 2011 17:52

Looks like a new world of worcraft scam seems to be doing the rounds recently.

 

It has come to our attention that you are trying to sell your personal World of Warcraft account(s). As you may not be aware of, this conflicts with the EULA and Terms of Agreement. If this proves to be true, your account can and will be disabled. It will be ongoing for further investigation by Blizzard Entertainment's employees. If you wish to not get your account suspended you should immediately verify your account ownership. 

 

E-mail Kick it! DZone it! del.icio.us Permalink


MSSQL - DBCC Check DB

7. June 2011 19:00

 

If you have ever come across a problem where the mssql host (eg windows) has crashed for some reson or another that you may have also come across the problem of having a possible issue with some of the databases coming corrupt where here is a way to run the dbcc check db command for all databases on an ms sql instance.

 

 

EXEC sp_MSforeachdb @command1 = 'DBCC CHECKDB(?) WITH NO_INFOMSGS; 
		PRINT ''Checked ? Status:'' + CONVERT(VARCHAR(255), @@ERROR)'

 

 

Example output is simple. Anything with a status which is no "0" should be investigated.

 

Checked master Status:0
Checked tempdb Status:0
Checked model Status:0
Checked msdb Status:0
Checked JEPS Status:0
Checked distribution Status:0
Checked Testing Status:0
E-mail Kick it! DZone it! del.icio.us Permalink