UMRA COM Object - Loop Through Data Table

9:52 AM / Comments (0) / by Tech Admin

If you haven’t already download the free trail version of User Management Resource Administrator here --> Download

If you want to learn the basics on how to connect to UMRA with its COM object, please see my original post on “Basics of UMRA COM”.If you’ve been following my blog you will see I’m a huge fan of UMRA and it’s ability to handle Identity Management of Active Directory Objects in a quick and user friendly fashion. In my previous post we talked about how we can use the UMRA COM method “connect” to talk to UMRA through a web page. We also know how to send data to UMRA COM and pull data back out of our projects. The example on our last blog post simply pulled and set data with the UMRA COM. Now, I will show you how I was able to create a table of data in a UMRA script, and loop through that table on a webpage.

How will this help you, you may ask? You will now have the ability of creating a table of data, it could be any set of Active Directory Objects. Maybe you want to pull all the users and a few attributes out of Active Directory….you can do this now.

So let’s get started, go ahead and open up UMRA if you haven’t already. Now drag/drop the action “Generate generic table”. This action can be found under the tree Variable actions --> Table --> Generate generic table.Here are the steps to configure the “Generate generic table” action.
Step 1: Double click on the “Generate generic table” table action in your script
Step 2: Click on “Configure…”
Step 3: In the “Table type” drop down select “LDAP query (Active Directory, Global Catalog)..
A. You will now see more options at the top of your script action

Step 4: Click on “LDAP Filter” tab
Step 5: Click the Drop down for “LDAP search Filters” and select “All Users” and click the “Insert” button
Step 6: Click the “Attributes” tab
Step 7: Click the “Add” button, to add these Attributes: sAMAccountName, DisplayName, Description
Step 8: Click the “Variable” tab and give the “Variable Name” %user_table%
Step 9: Click the “Run Test” tab, and then click the “Test…” button, you will now see your Users in the Table data area.

So now that we have a table of data, in our UMRA script, we now need to make a webpage, that will link up to this script, and loop through the tables contents.

Copy and Past this into a .asp webpage, and run it. Please see the notes on the script, since there are a few things you will need to change.

VBSCRIPT

'Create/Set
Variables

Dim RetVal

Dim
UMRA_Server

Dim
UMRA_Port

Dim
RowIndex


UMRA_Server =
"MyServerName"

UMRA_Port =
56814

RowIndex =
0
'End
Create/Set
Vairbales

Set Umra
= Server.CreateObject("UMRAcom.Umra") ' Create a New Instance of
UMRA
Set
UmraDataTable = Server.CreateObject("UMRAcom.UmraDataTable") ' Create a New
Instance of
UMRAcDataTable


RetVal=Umra.Connect(UMRA_Server,UMRA_Port) ' Connect to
UMRA

Response.write "Connection to UMRA:" & RetVal &
"
"

if
(RetVal=0)
then


RetVal=Umra.ExecuteProjectScript("My UMRA Script Name") ' Connect to your UMRA
script

Response.write "Connection to UMRA Script:" & RetVal &
"
"


if (RetVal=0)
then


RetVal=Umra.GetVariableDataTable("%UserTable%",UmraDataTable)

Response.write "Connection to UMRA DataTable:" & RetVal &
"
"


RowIndex=0 ' Create a new Row
Counter


RetVal=UmraDataTable.GetCellText(RowIndex,0,user_samaccountname) ' Column 0 of
our
datatable

RetVal=UmraDataTable.GetCellText(RowIndex,1,user_displayname) ' Column 1 of our
datatable

RetVal=UmraDataTable.GetCellText(RowIndex,2,user_description) ' Column 2 of our
datatable


While
(RetVal=0)


'Here is where we do the loop, and display on the page, the contents of the

Response.write "Account Name:"& user_samaccountname &
"
"

Response.write "Display Name:"& user_displayname &
"
"

Response.write "Description:"& user_description &
"

"


RowIndex1 = RowIndex1 + 1 ' After we get row 0, lets increment to get row 1
etc.



RetVal=UmraDataTable.GetCellText(RowIndex,0,user_samaccountname) ' Column 0 of
our
datatable


RetVal=UmraDataTable.GetCellText(RowIndex,1,user_displayname) ' Column 1 of our
datatable


RetVal=UmraDataTable.GetCellText(RowIndex,2,user_description) ' Column 2 of our
datatable


Wend


else

Response.Write "Form Project Not
Found"

end if
end
if


If everything is working fine, you will all your users in your webpage. If you don’t I added a little bit of error logic into the page, it should give you an idea of where its breaking. With this in mind, we will talk more in my next post about all the cool tips and tricks I found with error logic handling…so until next time!

0 comments:

 
-->