Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shaun 248 posts 475 karma points
    Nov 23, 2009 @ 15:41
    Shaun
    0

    Cannot retrieve member using GetMemberFromLoginName

    Hi

    I'm trying to retrieve a member in order to generate a new password for them.

    Here is my current code

    Response.Write("checking for " + tbUsername.Text);
                //send password
                if (tbUsername.Text != "")
                {
                    //query umbraco for username
                    Member memberExists = Member.GetMemberFromLoginName(tbUsername.Text);
                    bool valid = (memberExists == null);
                    if (valid)
                    {
                        Response.Write("valid member");
                        memberExists.Password = "fish";
                        memberExists.Save();
                        //generate password

                        //email password
                    }
                    else
                    {
                        lblError.Text = "Invalid username";
                    }
     

                }
                else
                {
                    lblError.Text = "Please enter a username";                
                }

    However my memberExists object is returning null each time, even for valid usernames.

    Can anyone help?

  • Shaun 248 posts 475 karma points
    Nov 23, 2009 @ 15:45
    Shaun
    0

    ignore me. bug in my code. Solved now.

  • BJ Patel 67 posts 172 karma points
    Jul 06, 2016 @ 06:29
    BJ Patel
    0

    Hi Shaun,

    Can you please share how you have fix this issue.

    Thanks

  • Micha Somers 133 posts 595 karma points
    Jul 06, 2016 @ 07:16
    Micha Somers
    0

    The code

    bool valid = (memberExists == null);
    

    should have been

    bool valid = (memberExists != null);
    

    Since the original posted question is rather old, you would probably (in case you use Umbraco 7.1 and 6.2 and newer) like to use another way to get the member by username by using the MemberService ( eg. the method GetByUsername(string username) ).

    For more info see: MemberService documentation

Please Sign in or register to post replies

Write your reply to:

Draft