Home > Uncategorized > Comparing two SPUser in SharePoint

Comparing two SPUser in SharePoint

Recently I was working on an EventHandler, Where I have to compare the User value in the Assigned To Field of the List with the other User value. Went down to Google and couldn’t find exact code I am looking for, here is the exact code that will do this.

 

SPUser spUser = GetSPUserOne();

SPUser spPrevUser = GetSPUserTwo();

For Windows Authentication This will do

 

if(spUser.Sid.Equals(spPrevUser.Sid))

{

…..

}

For FBA you have to follow this

 

if(spUser.UserToken.CompareUser(spPrevUser.UserToken))

{

…..

}

 

Hope this helps someone like me

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: