Wednesday, June 13, 2007 2:33 PM
Komal
Ole-DB Module: Enhanced
The earlier post on Ole-Db module was all about what the module does. This post is more about what one can do with the module. Specifically, this post would talk about how connection strings can be constructed dynamically using RunAs accounts. This post will also demonstrate (with examples) how other modules can use data generated by Ole-Db module.
A new RunAs profile is defined in MP (Management Pack) as follows and using OpsMgr Console, one should be able to add various RunAs accounts for different machines to it.
|
<SecureReferences>
<SecureReference ID="Demo.OleDB.ActionAccount" Accessibility="Public" Context="System!System.Entity" />
</SecureReferences> |
The above RunAs profile can be used to make connections to DB in a couple of ways:
1. An easy way to this is to specify credentials explicitly in the ConnectionString configuration element of Ole-Db Probe module as follows:
|
<ConnectionString>Provider=msdaora;Data Source=MyOracleDB;User Id=$RunAs[Name="Demo.OleDB.ActionAccount"]/UserName$;Password=$RunAs[Name="Demo.OleDB.ActionAccount"]/Password$</ConnectionString> |
2. Another way is to create a composite module type and associating the RunAs profile to that module type. This way one can use trusted connections, i.e., 'Integrated Security=true'.
See attached MP for more information.
In order to use output from OleDb module as configuration for other module, one should first understand the structure of OleDb data. More about it can be found here. OleDb module can be connected to any module that takes either System.BaseData or System.OleDbData as its input type (both datatypes defined in System.Library MP). Some example modules from System.Library MP that can be connected to OleDb would be System.Secure.CommandExecuterProbe, System.ExpressionFilter, System.Event.GenericDataMapper, etc.
Suppose, if we need the result of 1st column and 2nd row to be passed to the next module, it can be referred in the configuration as:
|
$Data/Columns[2]/Column[1]$ |
The configuration for System.ExpressionFilter module would look something like:
|
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Columns[2]/Column[1]</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="String">foo</Value>
</ValueExpression>
</SimpleExpression>
</Expression> |
The configuration for System.Secure.CommandExecuterProbe module would look something like:
|
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/DemoOleDb.vbs$ $Data/Columns[2]/Column[1]$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>DemoOleDb.vbs</Name>
<Contents>
<![CDATA[
'*************************************************************************
' Script Name - Demo Ole Db Script
'
' Purpose - Demonstrate how output from OleDbProbe module can be used
'
'*************************************************************************
Dim val
val = oArgs(0) ' "$Data/Columns[2]/Column[1]$"
]]>
</Contents>
<Unicode>1</Unicode>
</File>
</Files> |