2

Does anyone know exactly how this value is derived?

For half our team it seems to be "FistName.LastName". For the other half it is "FirstName LastName"...

I thought I would be able to find this out in five seconds of googling but all I can find are vague statements that say "the current user" or "the current users alias".

The MSDN article about query variables here describes it as being the current users alias but I have no idea what that means....

weegee
  • 3,256
  • 2
  • 18
  • 32
J M
  • 1,877
  • 2
  • 20
  • 32
  • 1
    An "alias" in this context is your domain log-on (ie, DOMAIN\username). This is used as they are guaranteed unique, while display names ("First Last") are not. What kind of problems are you seeing? – Edward Thomson Mar 23 '12 at 17:10
  • Hi Edward, I thank you for looking at this question. I am seeing that the alias is not alwaysthe username portion of the DOMAIN\username pair. If it were, then "@Me" for myself would not contain a space. The username I log on with is "FirstName.LastName". However, "@Me" for myself is "FirstName LastName". The reason I am asking is because I am going to be moving our TFS server and all our user accounts into a new domain on Monday/Tuesday. I am attempting to determine if all our queries willbreak or not. Thanks again for your interest. – J M Mar 23 '12 at 23:16

1 Answers1

1

When running a query in Visual Studio, TFS is building an SQL query for it. If you run SQL Server Profiler on the Tfs_DefaultCollection database you should notice a similar query:

exec sp_executesql N'set nocount on
declare @PersonId as int
declare @rebuildOK as int
declare @PersonName as nvarchar(255)declare @userSid as nvarchar(256)
set @userSid=@P1
exec @rebuildOK=dbo.RebuildCallersViews @PersonId output,@P1
if @rebuildOK<>0 return
DECLARE @AsOfUtc DATETIME; SET @AsOfUtc=@P2
DECLARE @Ids TABLE (Id INT NOT NULL)
INSERT INTO @Ids SELECT X.ID FROM (
SELECT @P3 AS ID
UNION ALL
SELECT @P4 AS ID
) as X

join  dbo.[WorkItemsLatestUsed] RL
on X.ID = RL.[System.Id]
where RL.[System.AreaID] not in
(
    select V.BelowID
    from dbo.[GetInverseUserPermissions](@userSid,1) V
)
option (loop join)


SELECT I.[System.Id],I.[System.Rev],I.[System.AreaId],I.[System.IterationId],I.[System.WorkItemType],I.[System.AssignedTo]
FROM @Ids Ids
JOIN [dbo].[WorkItemsAsOf] I with (nolock)
ON I.[System.Id] = Ids.[Id]
    AND I.[System.ChangedDate] <= @AsOfUtc
    AND @AsOfUtc < I.[System.RevisedDate]
OPTION (LOOP JOIN)
set nocount off
',N'@P1 nvarchar(4000),@P2 datetime,@P3 int,@P4 int',@P1=N'S-1-5-21-3698201826-3150490006-716737659-1107',@P2='2012-03-24 19:48:09.707',@P3=1266,@P4=1587

Note the use of dbo.RebuildCallersViews stored procedure which in turn serves the @userSid variable and ultimately the temporary I.[System.AssignedTo] column. Stored procedures in TFS database are protected so I couldn't decipher what's going beyond that.

KMoraz
  • 14,004
  • 3
  • 49
  • 82
  • The macros like @me are expanded by the client for rules engine evaluation. – Buck Hodges Mar 26 '12 at 15:26
  • Hi KMoraz and thanks for your reply. I didn't think of Profiler! I've been playing with it and am close to an answer but haven't quite got there yet. – J M Mar 27 '12 at 07:26
  • The posted profiler entry isn't the one that decides the list of items that will be displayed (I think). Those IDs have already been determined and are passed in in parameters p3 - px. A few profiler entries back, there is an entry that checks a table called [dbo].[Constants] for a string which in in my case is 'FirstName LastName'. The SID is only being passed in to the sproc you mentioned [dbo].[RebuildCallersViews]. – J M Mar 27 '12 at 07:29
  • So, I am close to an answer but not quite there. The actual questions are: "How does @Me get translated into the "FirstName LastName" value passed to this earlier set of SQL?" and "How does [dbo].[Constants] get populated in the first place?"... However, I will raise those separately if I can't work it out. I am accepting your answer as it got me in the right direction. – J M Mar 27 '12 at 07:32
  • @Buck Hodges: What you said sounds promising if I could fully understand it. I think you are saying that "@Me" is whatever we set it to be? That would be great because then, if I can find it, I can change it.... Googling for TFS client rules :) – J M Mar 27 '12 at 07:38
  • I meant to add that the [dbo].[Constants] table is full of all different formats: "FirstName LastName", "FirstName.LastName", "FirstName.LastName (DOMAIN\FirstName.LastName)", etc, etc.... – J M Mar 27 '12 at 07:41
  • I am thinking the entries in [dbo].[Constants] all look like user display names...and the reason we have all the different formats is because our own IT department changed our display name policy...and that as long as I ensure that both our display names and user names stay the same, the queries will still work..... – J M Mar 27 '12 at 07:59
  • I think the key is to understand how `I.[System.AssignedTo]` populated. However it's hardly feasible due to the stored procedures protection. – KMoraz Mar 27 '12 at 09:35
  • On the question of @me being translated, it's done in the work item tracking client OM. For the web, it's done in the web browser. By default, the string we use is the display name. That display name comes from Active Directory (whatever it is for the user's SID). – Buck Hodges Apr 27 '12 at 13:10