Thursday, 12 April 2012

How to get the user list from an OBIEE repository

I hardly needed the userlist from production OBIEE repository and few minutes of Googling landed me to a blog post by  John Minkjan, I have updated his script to write the output to a file with userid, name and groupname columns and thought of sharing with all, 

Here is the script with the steps.

'1. Navigate to the OracleBI\server\Bin\ folder
'2. Execute below command from DOS prompt to generate UDML export of the PRD
'  Note:Need to change the file name and path and provide valid userid/passwd
'E:\OracleBI\server\Bin> nQUDMLGen.exe -U <userid> -P <password> -R E:\OracleBI\server\Repository\RDWProdonline.rpd -O E:\backup\udmlfile.txt -S





'3. copy below content to a file and save it as getuserlist.vbs'------Start here-----------
'create file pointer variables for input and output files
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objInputFile = objFSO.OpenTextFile("E:\backup\udmlfile.txt", ForReading)
Set objOutputFile = objFSO.CreateTextFile("E:\backup\userlist.txt", TRUE)

'variable declaration
Const ForReading = 1
Dim arrFileLines()
dim strRLine
dim strUserid
dim strName
dim strGroup
dim strPrevStr
i = 0
strPrevStr=""

'preserve DECLARE USER line to string array
Do Until objInputFile.AtEndOfStream
   strRline = objInputFile.ReadLine
   if left(strRline,12) = "DECLARE USER" then
      Redim Preserve arrFileLines(i)
      arrFileLines(i) = Trim(strRline)
      i = i + 1
      strPrevStr="DECLARE USER"
   end if
   if instr(trim(strRline),"DESCRIPTION") > 0 and strPrevStr="DECLARE USER" then
      Redim Preserve arrFileLines(i-1)
      arrFileLines(i-1) = arrFileLines(i-1) & Trim(strRline)
   end if
Loop
objInputFile.Close

'Parse Userid, name & groupname and write to a file
For Each strLine in arrFileLines

   strUserid = MID(strLine ,15 , 50)
   IF instr(strline,"}" ) >0 THEN
      strName = MID(strLine , instr(strline,"{")+ 1, (instr(strline,"}") - (instr(strline,"{")+ 1)))
   ELSE
      strName = ""
   END IF
   IF instr(strline,"DESCRIPTION") > 0 then
      strGroup = MID(strLine , instr(strline,"DESCRIPTION")+ 13, (len(strline) - instr(strline,"DESCRIPTION") ) )
      strGroup = MID(strGroup  , 1, instr(strGroup,"}") - 1)
   ELSE
      strGroup = ""
   END IF
   objOutputFile.WriteLine(MID(strUserid ,1 , instr(strUserid, """")-1) &";" & strName & ";" & strGroup )
Next

objOutputFile.Close
'---------End here -------------
'4. Execute getuserlist.vbs from DOS Command Prompt
'5. Refer the file E:\backup\userlist.txt to view the list of users
'End of script

1 comment:

  1. Hi,

    it's really impressive, i tried run above script on machine which is listing only users but not groups..My requirement is to get the users list for each group..Can you please let meknow any suggestions

    ReplyDelete