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 am user user1 (which is also the user of the app pool of SharePoint, so when I log on with user user1 it says "Welcome System Account").

In my code, i want to test if a file is checked out by user1, so the result of the following:

file.CheckedOutBy.LoginName.ToLower() == userName.ToLower())

is always false (which is not correct). CheckedOutBy value is "SharePoint System" while username value is "user1".

How can I resolve this?

share|improve this question

Your best option is to not log in as the SharePoint farm account.

If you have to log in with this account, you could try the following.

SPUser user = myWeb.EnsureUser(userName);

if (file.CheckedOutBy.Id == user.Id)
    // your code here

Things to note Note:

  • myWeb is an SPWeb, you likely have one open already, if not you should be able to work backwards from the SPFile object.
  • I can't the format that EnsureUser needs the username to be in, you may need to append the domain? and it May throw exceptions if the user can't be found in your Auth Provider (AD? Forms?)
share|improve this answer

Thanks all, this is how i solved it:

file.CheckedOutBy.LoginName.ToLower() == web.CurrentUser.LoginName.ToLower() giving sharepoint\system on both sides, which is correct

share|improve this answer

try this


share|improve this answer

Your Answer


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

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