How can I obtain an Active Directory Group name from a SQL Server stored SID?

后端 未结 2 1678
谎友^
谎友^ 2020-12-21 05:04

This is a follow-up of a question I asked earlier this morning (posted here.) Following the instructions provided, I\'ve managed to query my SQL Server 2000 database for a

2条回答
  •  甜味超标
    2020-12-21 05:36

    If you're using sqlps (SQL Powershell host) which works against SQL 2000 (I've tested this on my 2000 instance) you can use this:

    $query = @"
    select sid from syslogins where isntgroup = 1
    AND name = 'CONTOSO\mylogin'
    "@
    
    invoke-sqlcmd -ServerInstance "myserver" -Database master -Query $query | 
    foreach {$SID = new-object security.principal.securityidentifier($_.SID,0); $SID.translate([system.security.principal.NTAccount]) }
    

提交回复
热议问题