Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a situation to get userid based on email address. I have a user email address which was already stored. Now the user changed his email address. By sending the old email address how to get the userid or can i get the new email address of the user by sending old email address.

Please help to find a solution for this. Thank you.

What I have tried:

JavaScript
var customerid_d = $.Deferred();
var prefix = "i:0#.f|membership|";
var Email = prefix + Email;
var customerid_url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteusers(@v)?@v='" + encodeURIComponent(Email) + "'";
getData(customerid_url, customerid_d, false).done(function(data) {
    var result = data.d;
    if (result != undefined && result != "" && result != null) {
        id = result.Id;
    }
});

function getData(url, d, async) {
    $.ajax({
        url: url,
        method: "GET",
        async: async,
        headers: {
            "Accept": "application/json; odata=verbose"
        },
        success: function(data) {
            d.resolve(data);
        },
        error: OnError
    });
    return d.promise();
}
Posted
Updated 21-Jan-21 4:09am
v2

1 solution

If he changed his email, it's a "new" user id. Unless you can cross-reference names and addresses, it's a "new" account (with perhaps a backward reference).

Email addresses are no longer the equivalent of a "nick name" that you change arbitrarily (unless your design accounts for it; which yours doesn't). And you should verify new email addresses with a confirmation message if you're at all serious.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900