I am creating a simple sequential workflow using VS 2015 in SP2013 on premise. Trying to assign a task to the user in a 'Domain\username' format. The problem is that it is creating a task but not assigning it to the specified user.

createTask1_TaskProperties1.AssignedTo = "Domain"+"\"+"username";

so when an item is added workflow is in progress and when you click on it you can see the task but 'Assigned to' column is empty.

I have tested assigning it to many users (Production users, test users). its only working with one live account of my colleague. that account was site collection admin so I added other test accounts and live accounts as site collection admin. it dint work.

I created a SharePoint group and assigned by retreiving from that group but still no luck. I used our own AD framework to retrieve the users and assign a task, but still no luck. I checked the logs and I compared the account for which it is working with the other which is not working and there is not much in the logs too: I will post the logs here Please see the logs below for working user and non working user: Please check and help me out as I am banging my head over this for two days.

enter image description here

  • Is the system configured for claims?
    – Nils
    Jul 1, 2019 at 6:46
  • yes @Nils this was an issue. after banging my head for 2 days I compared these two accounts and it turns out 'i:w#' thing before domain was the issue and i was trimming that part in the code. But a question here. why the other account which was working did not have that string before domain name? any idea.
    – user72480
    Jul 1, 2019 at 6:49
  • No. Hard to say. Maybe that account was logged in once before claims were configured? (Could be that some badly coded solution simply used SPWeb.EnsureUser() without the claim..)
    – Nils
    Jul 1, 2019 at 6:55
  • thanks for your help
    – user72480
    Jul 1, 2019 at 8:21

1 Answer 1


For completeness:

If claims are enabled, you need to provide the full claim, not only the "simple" login. Encoding the claim can be done via ConvertIdentifierToClaim. Whether claims are needed or not can be tested via UseClaimsAuthentication:

var userAccount = "domain\\user"
SPUser user;
if (web.Site.WebApplication.UseClaimsAuthentication)
  var claim = SPClaimProviderManager.Local.ConvertIdentifierToClaim(userAccount, SPIdentifierTypes.WindowsSamAccountName);
  user = web.EnsureUser(claim.ToEncodedString());
} else {
  user = web.EnsureUser(userAccount);

Now, the user is available in the web (so you're sure it can be assigned tasks). Use user.LoginName as assignee.

Your Answer

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

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