Brian,

There's probably a couple of tools/scripts out there, but here's one using
WMI and VBS.

Hope this helps,
Richard


option explicit

' declares
dim strUsrPDC, strUsrDom, strUsrAct, strUsrPwd, strUsrSid, strUsrName

' - target userid information -
' string sid to search for
strUsrSid = "S-1-5-21-xxxxxxxxxx-xxxxxxxxx-xxxxxxxxx-500" 
' domain userid (blank for impersonation)
strUsrAct = "DOMAIN\userid" 
' domain password (blank for impersonation)
strUsrPwd = "password_here" 
' domain controller name      
strUsrPDC = "domain_controller_or_server_name" 
' domain name    
strUsrDom = "domain_name_here"               

strUsrName = get_name(strUsrSid, _
                     strUsrAct, _
                         strUsrPwd, _
                         strUsrDom, _
                         strUsrPDC)

wscript.echo "the name associated with " & strUsrSid & " is: " & strUsrName
wscript.quit

' Retrieve the name associated with a SID using a WQL Query with
Win32_Account
'___________________________________________________________________________
_______
'
function get_name (strSid, strUsr, strPwd, strDom, strDC)
'___________________________________________________________________________
_______

        dim objWbemLocator, objWmiCon, objQuery, objName, strQry
        set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
        
        strQry = "SELECT Name FROM Win32_Account WHERE SID = '" _
                         & strSid & _
                         "' AND Domain = '" _
                         & strDom & "'"

        if len(strUsr) = 0 then 
                set objWmiCon = objwbemLocator.ConnectServer _
                                                (strDC, _
                                                "root\cimv2")
        else 
                set objWmiCon = objwbemLocator.ConnectServer _
                                                (strDC, _
                                                "root\cimv2", _
                                                strUsr, _
                                                strPwd)

                objWmiCon.Security_.AuthenticationLevel = 2

        end if 

        objWmiCon.Security_.ImpersonationLevel = 3
        set objQuery = objWmiCon.ExecQuery(strQry, "WQL")

        for each objName in objQuery
                get_name = objSid.Name
        next

        set objWbemLocator = Nothing
        set objWmiCon = Nothing
        set objQuery = Nothing
        set objname = Nothing

end function


> -----Original Message-----
> From: Brian Svidergol [mailto:bsvidergol@;sitelite.com] 
> Sent: Wednesday, October 23, 2002 7:38 PM
> To: [EMAIL PROTECTED]
> Subject: [ActiveDir] Opposite of GETSID.EXE (OT?)
> 
> 
> All- 
> I am looking for a utility (or script) that will translate an 
> account's SID into an account name.  I want to feed the 
> utility (or script) the SID and have the account named 
> returned via the command prompt. Basically, the tool would do 
> the opposite of getsid.exe (from Win2k Resource Kit).  
> getsid.exe will give me the SID if I supply the account name. 
> I've looked around but can't find anything. 
> Any ideas? 
> Thanks. 
> Brian 
> 
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to