6

Does every user that belongs to a site collection or a group in that site collection, have a user.ID?

I am iterating through a list of SPFieldUserValueCollection and am comparing the SPFieldUserValue.User.ID with the SPContext.Current.Web.CurrentUser.ID and want to make sure they will compare accurately.

Meyer Denney
  • 2,864
  • 8
  • 37
  • 64

2 Answers2

5

Yes, every user will have an ID. SPUser.ID is the integer ID of the user in the site collection. However, the ID is specific only to that specific site collection.

I would recommend using SPUser.LoginName instead.

Kit Menke
  • 4,193
  • 6
  • 32
  • 40
3

SPUser.ID only refers to the Item ID of their entry in that site collection's User Information List, so it's never guaranteed to be unique across a farm.

James Love
  • 25,512
  • 2
  • 45
  • 77
  • I understand it might not be unique across farms, but do you know if ever user in that farm will have an ID regardless if they are a member of the farm or just member of a group that belongs to the farm? – Meyer Denney Jun 07 '11 at 23:04
  • 1
    I would clarify that it isn't even unique across site collections. – Kit Menke Jun 07 '11 at 23:53
  • @Kit yeah, that's what I meant, though I guess how I wrote it could infer that I meant that it could be unique within a web app. Which it isn't. :) – James Love Jun 08 '11 at 07:15