SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to insert the user account for each user in a list column. As the list column is of type Person or Group, I need to convert the string type value to the person or group type. I have used the following function to convert the string value to person or group type :

    public SPFieldUserValue convertToPersonorGroup(string userid,SPWeb web)
    {            
        if(userid != null)
        {
            SPUser requireduser = web.EnsureUser(userid);
            SPFieldUserValue uservalue = new SPFieldUserValue(web, requireduser.ID,requireduser.LoginName);
            return uservalue;
        }
        return null;
    }

This function works fine for most of the user account names but in one of the account name it throws "The specified user indusa\ezend could not be found." exception.

I have also checked in the User Profile Service and this user exists there.but still I get this exception. I am not able to figure out the cause of the error. Kindly help.

Thanks in advance.

share|improve this question
    
EnsureUser is not using User Profile Service, but the authentication provider for your web application, which most likely is AD. Does the user exist in AD? – Per Jakobsen Mar 26 '12 at 6:53
    
Ya, the user does exist in the AD. – Mansi Desai Mar 26 '12 at 6:55
    
Quick suggestion: could you confirm if the working user are already available on the site and the not-working ones aren't? To be clearer: you may want to confirm if the method isn't working for all user that must be first-added to the web site or only for some specific users. – SPArchaeologist Mar 26 '12 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.