.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Membership - Change username

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

I am trying to use the email address as the username in my application but am obviously running into issues if the user needs to change their e-mail address.  I have searched the forums and have come across a couple posts that look like something I am trying to do but don't quite get me there.

 I found this post - http://forums.asp.net/t/911360.aspx?PageIndex=2 and was trying to use the code from Scott W.  The problem is that I am using VB and this example code is in C#.  I tried converting it but am having issues.

public bool UpdateUserNameAndEmail(string currentEmail, string newEmail)
MembershipUser memUser = Membership.GetUser(currentEmail);
  memUser.Email = newEmail;

View Complete Post

More Related Resource Links

change system account to username?

HI, I have created out-of-box workflow ,in the version history the modifiedby column  showing as system account instead of username. so want to display actual username instead of system account. help is appreciated. Thanks.

Change to AD username causes trouble for external access to WSS 3.0

I have one WSS 3.0 site hosted on a standalone server. I have extended the site into an external zone that authenticates with Digest authentication. This has been working fine for the past year or so. We have been looking into changing the user account naming scheme for Active Directory, and have been testing the change out on my own account. In doing so, I am still able to access our Sharepoint site from the Intranet zone on our internal network, but not from the external web address. I have tried removing my account from the site collection, and even going into the WSS_Content.AllUserData SQL table and changing the account name from DOMAIN\OldUserName to DOMAIN\NewUserName. No matter what I have tried, I get "HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials. Internet Information Services (IIS)" when I try to log in with any username.   Help?

error with Membership.GetUser(NewUserWizard.UserName)


on the third line of code I get message that "NewUserWizard" is not declared.  How can I remedy this?

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
        ' Get the UserId of the just-added user
        Dim newUser As MembershipUser = Membership.GetUser(NewUserWizard.UserName)
        Dim newUserId As Guid = CType(newUser.ProviderUserKey, Guid)

        ' Insert a new record into UserProfiles
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString()
        Dim insertSql As String = "INSERT INTO UserProfiles(UserId, HomeTown, HomepageUrl," & _
            "Signature) VALUES(@UserId, @HomeTown, @HomepageUrl, @Signature)"

        Using myConnection As New SqlConnection(connectionString)
            Dim myCommand As New SqlCommand(insertSql, myConnection)
            myCommand.Parameters.AddWithValue("@UserId", newUserId)
            myCommand.Parameters.AddWithValue("@HomeTown", DBNull.Value)

            myCommand.Parameters.AddWithValue("@HomepageUrl", DBNull.Value)
            myCommand.Parameters.AddWithValue("@Signature", DBNull.Value)

Membership.GetUser().UserName On Login Page



I have an Employee class in my App_Code folder.  On my login page I am trying to create an Employee using the asp.net username as a parameter in my Employee constructor.

 I have tried creating the employee in the page load event when it is a post back.  I have tried doing it in the Login1_LoggedIn event.  For some reason I cannot pull the username in either one of these places, but if I redirect after logging in and do the same thing on another page, it works.

How can I get it done on the login page?


  Dim em As Employee

        em = New Employee(CInt(Membership.GetUser().UserName))


Membership Provider - Login fails after change in database name


Hi Experts,

I am in the process of deploying an website developed in ASPNet 2.0 and using the login control and membership provider features. The site was deployed fine and was working perfectly till I changed the database name and user name to access the database. I changed the accordingly in the web.config to point to the new database. Everyting is working file except when the user tries to login into the website.

The error log says that login failed because it is trying to open the old database.

Any idea how I can solve the issue? Thanks for your help.



Change UserName and Password Requirements



 How do i change the default user name and password requirements.   I wanna make the user name the person email address and i don't want it case sensitive.. I wanna make the mininum password to be 4 characters or numbers case sensitive.  The maxinum password can be 10 characters or numbers.



Username Change process for SharePoint

We have noticed that when we change a username in Active Directory (usually due to a marital status change), we run into some issues on the SharePoint side of the house. 

After we change things in Active Directory we typically wait for a full import/crawl to be done by the Search Services Administration schedules.  Once both of those run, the user is able to log into the SharePoint site and have the "welcome" link reflect the new Display Name.  However, if we search for the user using People search, it returns the right display name but still tied to the old SAM Account ID.  We also have some online forms that utilize an Exchange Address Book lookup.  If we look the user up, they show up twice (once as the old Account ID and once as the new Account ID).  We have also tried deleting the user object out of the User Profile Service in Central Admin adn out of the "All People" groups.  If we allow another import/crawl after that, everything seems to be okay, but the user does not get populated back into the "all Users" SharePoint group (they can log in and access everything they are supposed to).

Since we are kind of grasping at straws for an "official" process here, can anyone help us to see if what we are doing is right, wrong, or indifferent?  Thanks!


How to Localize Windows Forms and Change the Language at Runtime

Localization is the process of customizing your application to a particular language, culture or locale. Visual Studio provides support for localizing Windows Forms with much ease. In this article, we will see how to localize windows forms and give the user the ability to change to his preferred language at runtime.
When you run a localized application, the appearance is determined by two culture values. The UICulture property is used to specify which resource files will be loaded for the form. The Culture property, on the other hand, determines how strings such as dates, numerals, and currency amounts are formatted.
Let us see the steps required to create a localized form. You can then expand this example and adopt the same approach for the rest of the forms in your project

Finding username


Im running a query where it selects a property from the user with the matching username but i dont know how to find out the username of the currently loggedin user.

Please Help!

Selected to change the background color of the page



As this site, http://www.borfin.com.tr/genel/Default.aspx, How can I change the background color selected pages.

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



Multiple membership providers



In my web.config I have:

        <add name="ADProvider1"
        <add name="ADProvider2"

If I just have ADProvider1 it works, when I add ADProvider2, even though for testing I only use ADProvider1 I get an error: "Unable to establish secure connection with the server"

Am I adding the second provider to the membership section incorrectly?



Replacement options for Membership


Hi everyone,
     I tried to use Microsoft's Membership option for signing up new users and authenticating them on subsequent pages, but it has not worked very well. The biggest issue has been with the REMEMBER ME function. With this checked, I am randomly logged out in the middle of some functions and some pages always show me as not authenticated, while others properly show me as authenticated. I built a site based on VB.
I was wondering what other people are using ro register users and monitor authentication and also if anyone has had better experiences with other solutions. 

Hi everyone,

     I tried to use Microsoft's Membership option for signing up new users and authenticating them on subsequent pages, but it has not worked very well. The biggest issue has been with the REMEMBER ME function. With this checked, I am randomly logged out in the middle of some functions and some pages always show me as not authenti

Pass ASP.NET membership identity object across domain?


I am trying to figure a way to SSO with ASP.NET membership and role model.

I can implement custom membership provider which consume web services hosting on a server.

With encryption of data. No problem.

But my question is, If I sign on a website with my provider, got my identity object on that application,

could I pass it to another website on another domain which use the same provider and by doing so, do not need to login again?

If this is possible, I am going to implement this solution. Please tell me what's your take on this.

Membership Search user


Is there a membership function to search a username Like this:   LIKE '%UserName%' ?

This is not working.

MembershipUser User = Membership.GetUser("%" + TextBox1.Text + "%");

Thank you.

Membership Provider Conn String


Hello. I've bee successfully using the Asp.Net Membership Provider in my VB.Net 3.5/SQL 2005 web app for a year now (Site A). However, I've added 2 new sites (B and C) (both with their own DB) and now I see a problem. It looks like users that get created for sites B and C also get created in site A. Roles that I create for B and C only get created in A. I think it is a conn string problem.

When I created A, I adde the conn string to my machine.config (not sure why I did this or if it is even needed)...


         <add name="LocalSqlServer" connectionString="Data Source=VS689\SQLEXPRESS;Initial Catalog=SiteA;USER ID=sa;PASSWORD=123456"/>


                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=blahblah" connectionStringName="LocalSqlS

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend