List of users in windows group

  • Is there any other way of getting list of members from any windows group other than using

    EXEC xp_logininfo

    when i use this i am getting list for some groups but not for all groups, what is the trick?

  • Hi,

    Try the following

    DECLARE @LoginName sysname

    DECLARE @sql NVARCHAR (2000)

    BEGIN

    DECLARE cur_Loginfetch CURSOR FOR

    SELECT [name] FROM master.sys.server_principals WHERE TYPE = 'G'

    OPEN cur_Loginfetch

    FETCH NEXT FROM cur_Loginfetch INTO @LoginName

    WHILE @@FETCH_STATUS = 0

    BEGIN

    EXEC xp_logininfo @LoginName , 'members'

    FETCH NEXT FROM cur_Loginfetch INTO @LoginName

    END

    CLOSE cur_Loginfetch

    DEALLOCATE cur_Loginfetch

    RETURN

    END

Viewing 2 posts - 1 through 1 (of 1 total)

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