How to tell *who* is using RMS in your environment quickly.

I've had several customers ask me for a quick way to get a list of all of the users that are using RMS. The admin UI, will tell you how many people are, but not 'who' is using it.
Here is a vbscript I wrote that should tell you (assuming you have access to the RMS SQL server, locally, or remotely)
Due to my severe laziness the error trapping isn't that great...but I really just needed a quick sample to use as a model, and usually let my customers do the heavy error trapping in their own apps. This way I can truly say "Use at your own risk"...which I am also saying to you. 😉
' rmsusers.vbs - A simple script to match up the SDDL sids in the RMS
' dbase to user accounts
Option Explicit
Dim strComputer, strRoot, strDbase, strSQL, strConn
Dim objRoot
Dim conn,ldpconn
Dim rs,rsUser
Dim objArgs
Set objArgs = Wscript.Arguments
If objArgs.Count = 0 Then
End if
If lcase(objArgs(0)) = "internal" Then
 strComputer = "np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query"
 strComputer = objArgs(0)
End If
Set objRoot = GetObject("LDAP://RootDSE")
strRoot = objRoot.Get("defaultnamingcontext")
Set objRoot = Nothing
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.RecordSet")
With rs
End With
With conn
 strDbase = "master"
 .open strConn    
 strSQL = "Select Name From SysDatabases Where" & _
                       " Name like 'DRMS_Config%'"
 rs.Open strSQL,conn
End With
If rs.RecordCount > 0 Then
 strDbase = rs.Fields("name").Value
 Wscript.Echo "++++Found Database:" & strDbase & ".++++" & vbcrlf & vbcrlf
 strSQL = "Select s_Sid from UD_WindowsAuthIdentities"
 GetConn() strConn strSQL,conn
 If rs.RecordCount > 0 Then
  Wscript.Echo "There were " & rs.RecordCount & " users found."
  Do until rs.EOF
  Wscript.Echo "No users found in UD_WindowsAuthIdentities Table"
 End If
 Wcript.Echo "Could not find RMS Configuration Dbase"
End if
'GetConn - Probably not needed. I thought I'd be making more connections
Sub GetConn()
 strConn = "Provider=SQLOLEDB;Data Source=" & strComputer & ";" & _
"Trusted_Connection=Yes;Initial Catalog=" & strDbase
End Sub
'Resolve Name - Will spit out the user names based on SDDL sid
Sub ResolveName (strSID)
 Set ldpconn = CreateObject("ADODB.Connection")
 With ldpconn
  .Provider = "ADSDSOObject"
  .Open "ADSProvider"
  strSQL = "<GC://" & strRoot & ">;(&(objectclass=user)(objectSID=" & strSID &"));name,mail;subtree"
  Set rsUser = .Execute(strSQL)
  If rsUser.RecordCount > 0 Then
 Wscript.Echo "**-" & rsUser.Fields("name").Value & _
        "-" & rsUser.Fields("mail").Value
 Wscript.Echo "Unresolved: " & strSID
  End If
  Set rsuser = nothing
  Set ldpconn = nothing
 End with
End Sub
'CleanUp - If we bail - try to clean up
Sub CleanUp
set rs = Nothing
set conn=nothing
End Sub
'ShowUsage - How to use the script
Sub ShowUsage
 Wscript.Echo "Usage:>cscript rmsusers.vbs rms_sql_server"
 Wscript.Echo "Usage:>cscript rmsuser.vbs rms_sql_server\instance"
 Wscript.Echo "Usage:>cscript rmsuser.vbs internal"
End Sub

Comments (3)

  1. Anonymous says:

    hmmm..I'm not sure if I should be happy, or offended that I'm apparently being PingBacked from someplace called Geek Lectures.

    I'm torn.

  2. Anonymous says:

    在 RMS 目前的管理報表中(如下圖),只有多少個使用者使的總數量,並沒有明確列出是那些使用者使用過 RMS 的服務。 要如何得知這些使用者的 清單 呢?這個問題有很多的朋友問過我, 這兩天看到同事 Jason

Skip to main content