Hey Friends I am trying to develop a web part in that I am fetching the user name.
But doing this I am getting the error that User cannot be found
.
But the main thing is that in the line where I am getting this error has the same code written in the above line and it is passed through that and gives me the error in the bellow line.
Code :
string pc = ddlPrincipleConsultant.SelectedItem.Text;
string associateconsultant = "";
string domain = System.Environment.UserDomainName;
string authoby = ddltravelcost.SelectedItem.Text;
SPUser user = web.EnsureUser(pc); //It gives me proper user name
SPUser authorizedby = web.EnsureUser(authoby);// Here I get the error
Here is the screenshot of the error.
And I also tried with below code.
SPUser user = web.AllUsers[pc];
SPUser authorizedby = web.AllUsers[authoby];
But in this it gives me error in both. Both statement do not find the users.
Please Help me to solve this prolem..