I'm trying to create a task, in a VS 2010 workflow, and assign it to one of our domain users. This guy's not a site collection user, but I'm assuming that he'll be added to Sharepoint automatically. He's also located in another company branch, somewhere in South Africa. The code I'm using is something like

    private void CreateTask_MethodInvoking(object sender, EventArgs e)
        TaskProps = new SPWorkflowTaskProperties();
        TaskId = Guid.NewGuid();

        TaskProps.AssignedTo = @"MYDOMAIN\username";
        TaskProps.Title = "Sample task";

Once I deploy and run the workflow, the task gets created just fine, but the "Assigned To" field is blank. The event log shows that "User does not exist or is not unique."

Furthermore, if I create a task by hand, and put MYDOMAIN\username in the "Assigned To" field, it gets created with no problems, and the user gets imported to the site collection. After that, the workflow runs all right. Manually adding each of our 200+ domain users to the site collection is not an option, though. Suggestions?

2 Answers 2


The assumption that the user is added to the site collection is not true. You cannot assign a task to a user who does not have permissiosn in the site collection, however you do not have to add every user manually.

  • do as MBSurf suggests and add the user in code
  • put all the users in a group in AD (if you don't already have one) and assign the group to the SharePoint site
  • Grant "All Authenticated Users" permissions to the task list so tasks can be assigned to anyone...

In MOSS, I would do something like below:

        SPUser spUser = null;

            // Attempt to get the user first
            spUser = userCollection[user];
        catch (Exception)
            // The User does not exist, so we need to add them
            userCollection.Add(user, string.Empty, user, string.Empty);
            spUser = userCollection[user];

Then, I would save spUser in the Assigned To field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.