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
4 comments:
Thanks...
I will use UserToken.CompareUser(). I think this might also work with Windows Authentication..
greetz Sander (someone like you)
using the SID worked like a charm. Solved the problem I had when checking for list item alerts before creating a new alert. Just comparing the alert's SPUser to my SPUser was never finding a match and thus casuing duplicate alerts. Thanks for the tip!
Yes it helps :)
Thank you very much.
sure did help me :)
Post a Comment