XPath Filter to create a set of all Direct & Indirect reports to a CIO
Hi All,
I have been working on a XPath filter to create a set of all Direct & Indirect reports of a CIO. Looking at Bobby & Nima's blog: I was hoping this filter: /Person[ descendant-in(‘Manager’ , /Person[DisplayName = ‘MyNameIsCIO’])] would do the trick.
However, I do get the following exception when I try to use it:
Microsoft.ResourceManagement: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ResourceManagement.Query.XPath.XPathBuilder.FixBareType(QueryNode node)
at Microsoft.ResourceManagement.Query.XPath.XPathBuilder.EndBuild(QueryNode result)
at Microsoft.ResourceManagement.Query.XPath.XPathParser`1.Parse(XPathScanner scanner, IXPathBuilder`1 builder, LexKind endLex)
at Microsoft.ResourceManagement.WebServices.XPathParser.XPathDialectParser.ParseXPathExpression(String expression)
at Microsoft.ResourceManagement.WebServices.XPathParser.XPathDialectParser.ParseEnumerate(String filter)
at Microsoft.ResourceManagement.WebServices.DialectParser.ParseFilter(String serializedFilterType)
at Microsoft.ResourceManagement.ActionProcessor.FilteredResourceActionProcessor.FilteredResourceActionProcessHelper.ToQueryFilter(String serializedFilterType)
at Microsoft.ResourceManagement.ActionProcessor.FilteredResourceActionProcessor.FilteredResourceActionProcessHelper.TryParseFilter(String filterXml, QueryFilter& queryFilter, Boolean& temporal)
at Microsoft.ResourceManagement.ActionProcessor.FilteredResourceActionProcessor.FilteredResourceActionProcessHelper.DoPreProcessRequest(RequestType request)
at Microsoft.ResourceManagement.ActionProcessor.FilteredResourceActionProcessor.PreProcessRequestFromAttribute(RequestType request)
at Microsoft.ResourceManagement.ActionProcessor.ActionDispatcher.PreProcessRequestFromAttribute(RequestType request)
at Microsoft.ResourceManagement.WebServices.RequestDispatcher.CreateRequest(CreateRequestDispatchParameter dispatchParameter)
at Microsoft.ResourceManagement.WebServices.RequestDispatcher.CreateRequest(UniqueIdentifier requestor, UniqueIdentifier targetIdentifier, OperationType operation, String businessJustification, List`1 requestParameters, CultureInfo locale, Boolean isChildRequest, Guid cause, Boolean doEvaluation, Nullable`1 serviceId, Nullable`1 servicePartitionId)
at Microsoft.ResourceManagement.WebServices.RequestDispatcher.CreateRequest(UniqueIdentifier requestor, UniqueIdentifier targetIdentifier, OperationType operation, String businessJustification, List`1 requestParameters, CultureInfo locale, Boolean isChildRequest, Guid cause, Boolean doEvaluation)
at Microsoft.ResourceManagement.WebServices.ResourceManagementService.Put(Message request)</Data>
And this exception too:
System.InvalidOperationException: Invalid token in XPath expression
Any thoughts what might be going wrong?
Appreciate your help!
Thanks & Regards,
Jameel Syed
Principal Consultant,
fimGuru - Your window into simplified identities
jameel.syed@fimguru.com - http://www.fimguru.com
March 4th, 2010 7:40pm
Hi Jameel, The descendants() and descendant-in xpath functions are no longer available in query or sets in RTMPlease refer to the post @ http://social.technet.microsoft.com/Forums/en-US/ilm2/thread/5b78c6c4-1f2b-4743-a618-19138d79410e?prof=requiredThanks,Sri
Free Windows Admin Tool Kit Click here and download it now
March 5th, 2010 1:10am
Sri,
Thanks for referring me to this post. What is the recommended alternative to descendants and descendants-in functions? I am sure there must be a better way of doing this which is why these functions were deprecated.
Any thoughts?
Thanks & Regards,
Jameel Syed
Principal Consultant,
fimGuru - Your window into simplified identities
jameel.syed@fimguru.com - http://www.fimguru.com
March 5th, 2010 2:13am
Hi...
I made a Powershell Script that helped me.
Here is a Powershell Script that writes in the console the name of the people that directly and/or indirectly reports to a manager.
To use this script just type the manager's name after the script name.
script.ps1 'manager name'
set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
clear
If($args.count -ne 1) {Throw "Type a Name!"}
$ManagerName = $args[0]
$Filter = "/Person[DisplayName='$ManagerName']"
If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {Add-PSSnapin FIMAutomation}
$curObject = export-fimconfig -uri $URI –onlyBaseResources -customconfig ($Filter) -ErrorVariable Err -ErrorAction SilentlyContinue
If($Err){Throw $Err}
If($curObject -eq $null) {Throw "Name not found!"}
$attrObjectID = (($curObject.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "ObjectID"}).Value).split(":")[2]
$Filter_Manager = "/Person[Manager = '$attrObjectID']"
[array]$curObject_Direct = export-fimconfig -uri $URI –onlyBaseResources -customconfig ($Filter_Manager) -ErrorVariable Err -ErrorAction SilentlyContinue
write-host "This people Direct Reports to $ManagerName"
$arrayIndireto = @()
foreach($DirectReport in $curObject_Direct)
{
write-host " +" ($DirectReport.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value
$Direct = (($DirectReport.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "ObjectID"}).Value).split(":")[2]
$Filter_Direct = "/Person[Manager = '$Direct']"
[array]$curObject_Indirect = export-fimconfig -uri $URI –onlyBaseResources -customconfig ($Filter_Direct) -ErrorVariable Err -ErrorAction SilentlyContinue
foreach($InDirectReport in $curObject_Indirect)
{
$Indireto = ($InDirectReport.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value
if($Indireto.Length -gt 1)
{
$arrayIndireto += $Indireto
}
}
}
write-host ""
write-host "This people Indirect Reports to $ManagerName"
foreach($IndirectReport in $arrayIndireto)
{
write-host " --" $IndirectReport
}
write-host ""
write-host ""
Trap
{
Throw $_.Exception.Message
Exit 1
}
I hope that this will help you in anyway
Cheers,
***** Paulo H. Campos - So Paulo/Brasil ***** http://identitypedia.blogspot.com (in PT-BR)
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2010 8:49am