How do you identify server roles for a user who logins into SQL Server via a Windows Group login?

  • Access to SQL Server is restricted by logins associated with Windows Groups.

    Both server-roles and database-users are assigned to the Windows group logins.

    However, when a user logs in, the USER_ and SUSER_ name and ID functions return the Windows account name of the user.

    Therefore, how do I determine the roles associated with that user when only the windows groups exist within the role/principal maps?

  • select * from sys.syslogins

    Hope this query give you your desire result.

    it contain all log in name role associated with log in name,

    try it

  • Could you explain with more details your environment? , I don't follow you

    Regards

    SNM

    Try Free Microsoft SQL Server Data Collector & Performance Monitor.

    http://www.analyticsperformance.com[/url]

    @nalyticsperformance - Microsoft SQL Server & Windows Server Free Data Collector

  • Try this example taken rom BOL ---> IS_SRVROLEMEMBER (Transact-SQL)

    IF IS_SRVROLEMEMBER ('sysadmin') = 1

    print 'Current user''s login is a member of the sysadmin role'

    ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0

    print 'Current user''s login is NOT a member of the sysadmin role'

    ELSE IF IS_SRVROLEMEMBER ('sysadmin') IS NULL

    print 'ERROR: The server role specified is not valid.'

    ...for each server role.

  • dmoldovan (12/1/2009)


    Try this example taken rom BOL ---> IS_SRVROLEMEMBER (Transact-SQL)

    IF IS_SRVROLEMEMBER ('sysadmin') = 1

    print 'Current user''s login is a member of the sysadmin role'

    ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0

    print 'Current user''s login is NOT a member of the sysadmin role'

    ELSE IF IS_SRVROLEMEMBER ('sysadmin') IS NULL

    print 'ERROR: The server role specified is not valid.'

    ...for each server role.

    Thank you. This solves my problem.

  • You're welcome 🙂

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply