2

I query sys.login_token to check if the current user is in a particular windows group.

SELECT principal_id, name, [type], usage
FROM sys.login_token
WHERE principal_id > 0

But after I added the user to a new group, the group didn't show up in the query result.

I tried to log out and disconnect but it appears only restart the SQL Server Service will refresh the result of sys.login_token.

Therefore, is there any way(stored procedure or something) that I can trigger SQL Server to update sys.login_token?

1 Answer 1

2

The client refreshes the login token, not SQL Server.

Either log out/in, or lock+unlock their PC
This forces an AD authentication(token rebuild)

There also other methods...

  • Serverfault also suggest crashing explorer.exe on the client
  • I've not tried the klist approach. YMMV

Until the token is rebuilt, the login token as read by SQL Server will be stale.

1
  • You were right, re-login will refresh it and when I tested logout yesterday I queried from another machine by ssms and didn't reconnect which make sense the result set didn't change at all, silly me. Jan 4, 2019 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.