Hi!
Imagine situation: there are several employees with name John Smith in Your company. Each of them has his own user name ('mydomain\smith1', 'mydomain\smith2'), but display name in WSS 3.0 for all of them is the same - John Smith.
In custom web part I need to find list items with user 'mydomain\smith1' in column 'Empoyee' using SPQuery object. I create following CAML query:
---------------
Dim MyQuery As New SPQuery
MyQuery.Query = "<Where>" + _
"<Contains>" + _
"<FieldRef Name=""Employee"" />" + _
"<Value Type=""User"">John Smith</Value>" + _
"</Contains>" + _
"</Where>"
---------------
I pass display name of user in query (John Smith), so I also get list items with user 'mydomain\smith2' in column 'Employee' because this user has the same display name. But I need to get items only for user 'mydomain\smith1'.
Unfortunately I haven't found an easy way how to return items only for the user 'mydomain\smith1'. Passing user name or string in format 'UserID;#DisplayName' (like it is written in column) does not work.
Is there any way I can get items only for 'mydomain\smith1'
Similar situation is also with Lookup columns - different items in lookup list can share the same value in column that is specified as a display column for a lookup column.