UniquenessValidationXPath and XPath variables question
Hi,
reading this http://technet.microsoft.com/en-us/library/ee534918(WS.10).aspx I found that have no idea how to use <Attribute_xxx> variables in RCDC forms.
What I mean -
<my:Property my:Name="UniquenessValidationXPath" my:Value="/Role[RoleName='%VALUE%' and ParentApp='objectid_here']" /> works fine as expected
but ParentApp is a reference in the form so I want to do something like
<my:Property my:Name="UniquenessValidationXPath" my:Value="/Role[RoleName='%VALUE%' and ParentApp='%ParentApp%']" />
and have dynamic ParentApp objectID in my filter but FIM raises an error saying 'This uniqueness validation for this value cannot be evaluated. Try again.'
Question:
how to use <Attribute_xxx> value from the same object creation/editing form for uniqueness validation?
October 25th, 2010 5:48pm
ok, looking at debug logs of FIM Service I found that its not FIM Service issue.
Enumerate(/Role[RoleName='Administrator2' and ParentApp='%ParentApp%']), Principal(7fb2b853-24f0-4498-9534-4e10589723c4)
XPathDialectParser.ParseXPathExpression.Enter(/Role[RoleName='Administrator2' and ParentApp='%ParentApp%'])
so %ParentApp% is not parsed at all...
any ideas?
Free Windows Admin Tool Kit Click here and download it now
October 26th, 2010 6:01am
the answer seems to be in here for Microsoft.IdentityManagement.WebUI.UniversalObjectControl.Controls.UocTextBox:
long num = ConfigurationModelBase.CountResource(this.ReplaceXPathValue(this.uniquenessValidationXPath, inputContainsSingleQuote, inputContainsDoubleQuote));
from
private void Validator_ServerCustomValidate(object source, ServerValidateEventArgs args)
{
this.EnsureChildControls();
args.IsValid = true;
if (!string.IsNullOrEmpty(this.textBox.Text) && !string.IsNullOrEmpty(this.uniquenessValidationXPath))
{
bool inputContainsSingleQuote = this.textBox.Text.Contains("'");
bool inputContainsDoubleQuote = this.textBox.Text.Contains("\"");
CustomValidator validator = source as CustomValidator;
if (inputContainsSingleQuote && inputContainsDoubleQuote)
{
validator.ErrorMessage = UniversalObjectControl.ValidationError_NoBothSingleDoubleQuotes;
args.IsValid = false;
}
else
{
long num = ConfigurationModelBase.CountResource(this.ReplaceXPathValue(this.uniquenessValidationXPath, inputContainsSingleQuote, inputContainsDoubleQuote));
if (num == -1L)
{
validator.ErrorMessage = UniversalObjectControl.ValidationError_UniquenessValidationCannotBeEvaluated;
args.IsValid = false;
}
else if (num > 0L)
{
args.IsValid = false;
}
}
}
}
and later:
private string ReplaceXPathValue(string originalXpath, bool inputContainsSingleQuote, bool inputContainsDoubleQuote)
{
string input = originalXpath;
if (inputContainsSingleQuote || inputContainsDoubleQuote)
{
string str2;
string str3;
string str4;
if (inputContainsSingleQuote)
{
str2 = "'%[a-zA-Z]*%'";
str3 = "'%VALUE%'";
str4 = "\"%VALUE%\"";
}
else
{
str2 = "\"%[a-zA-Z]*%\"";
str3 = "\"%VALUE%\"";
str4 = "'%VALUE%'";
}
Regex regex = new Regex(str2);
foreach (Match match in regex.Matches(input))
{
if (string.Compare(match.Value, str3, StringComparison.OrdinalIgnoreCase) == 0)
{
input = input.Replace(match.Value, str4);
}
}
}
Regex regex2 = new Regex("%[a-zA-Z]*%");
foreach (Match match2 in regex2.Matches(input))
{
if (string.Compare(match2.Value, "%VALUE%", StringComparison.OrdinalIgnoreCase) == 0)
{
input = input.Replace(match2.Value, this.textBox.Text);
}
}
return input;
}
So that looks like an answer to why only '%VALUE%' is parsed and not other attributes.
I wish I would know whether I'm doing something wrong or documentation for RCDC is wrong about <Attribute_xxx>.
p.s. the goal was to have a unique role name not in the global scope but per application
October 26th, 2010 8:14am
You actually need to specify "%Attribute_yourAttributeNameGoesHere%" like so:
<my:Property my:Name="UniquenessValidationXPath" my:Value="/Role[RoleName='%VALUE%' and ParentApp='%Attribute_ParentApp%']" />
Free Windows Admin Tool Kit Click here and download it now
October 27th, 2010 3:12am
Paul, it was so easy so I've started with <my:Property my:Name="UniquenessValidationXPath" my:Value="/Role[RoleName='%VALUE%' and ParentApp='%Attribute_ParentApp%']"
/>
and the problem is that it just doesn't work :)
it raises 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)
because of this
XPathDialectParser.ParseXPathExpression.Enter(/Role[RoleName='Cashier1' and ParentApp='urn:uuid:57d7933d-51b4-46e5-9eed-590194f2efd5'])
Enumerate(/Role[RoleName='Cashier1' and ParentApp='urn:uuid:57d7933d-51b4-46e5-9eed-590194f2efd5']), Principal(7fb2b853-24f0-4498-9534-4e10589723c4)
it doesn't remove urn:uuid
So, I thought that its either a bug or I'm doing something wrong.
and as for me function
ReplaceXPathValue should remove 'urn:uuid' from XPATH string.
October 27th, 2010 3:36am
Paul, Markus
I really want to here from MS whether its a bug in Microsoft.IdentityManagement.WebUI.UniversalObjectControl.Controls.UocTextBox.ReplaceXPathValue
or its not supposed to have reference attributes from RCDC forms in UniquenessValidationXPath.
I do understand that all reference values in requests have URN:UUID: prefix and I had to subtract it in my WF activities to convert them to GUID values to use in ReadResourceActivity.
But having this prefix inside UniquenessValidationXPath for reference values makes it useless... as FIM Xpath version doesn't support "concat", "string" or "fn:replace" functions.
I mean <my:Property my:Name="UniquenessValidationXPath" my:Value="/Role[RoleName='%VALUE%' and ParentApp=fn:replace('%Attribute_ParentApp%','urn:uuid:','')]"
/> doesn't work by design :)
Free Windows Admin Tool Kit Click here and download it now
October 29th, 2010 2:27am
I'm seeing the same issue using %ObjectID% in a SearchScope or ListFilter:
<my:Property
my:Name="ListFilter"
my:Value="/Person[stActiveAssignmentIDs = '%ObjectID%']"/>
stActiveAssignmentIDs is a single-valued Reference attribute. The Trace log shows the following requests:
Enumerate(/Person[stActiveAssignmentIDs = '%ObjectID%']), Principal(7fb2b853-24f0-4498-9534-4e10589723c4)
XPathDialectParser.ParseXPathExpression.Enter(/Person[stActiveAssignmentIDs = '%ObjectID%'])
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)
I think the control(s) are broken - I'm using this in a UocIdentityPicker.Brad Turner, ILM MVP - Ensynch, Inc - www.identitychaos.com [If a post helps to resolve your issue, please click the "Mark as Answer" or "Helpful" button at the top of that post. By marking a post as Answered or Helpful, you help others
find the answer faster.]
November 3rd, 2010 8:00pm
Confirmed that only some of the controls have issues - the UocListView does not exhibit this behavior:
Works
<my:Control my:Name="stAssignedListView" my:TypeName="UocListView" my:Caption="All Assigned Counselors to this team" my:ExpandArea="true">
<my:Properties>
<my:Property my:Name="ColumnsToDisplay" my:Value="DisplayName,JobTitle,Email,OfficePhone,stActiveAssignmentEndDate,stActiveAssignmentIDs" />
<my:Property my:Name="ResultObjectType" my:Value="superTeamAssignment"/>
<my:Property my:Name="EmptyResultText" my:Value="There are no members according to the filter definition." />
<my:Property my:Name="PageSize" my:Value="8" />
<my:Property my:Name="SearchControlAutoPostback" my:Value="false" />
<my:Property my:Name="SearchOnLoad" my:Value="true" />
<my:Property my:Name="ShowTitleBar" my:Value="true" />
<my:Property my:Name="ShowActionBar" my:Value="false" />
<my:Property my:Name="ShowPreview" my:Value="false" />
<my:Property my:Name="ShowSearchControl" my:Value="false" />
<my:Property my:Name="EnableSelection" my:Value="false" />
<my:Property my:Name="ItemClickBehavior" my:Value="ModelessDialog" />
<my:Property my:Name="ListFilter" my:Value="/Person[stActiveAssignmentIDs = '%ObjectID%']" />
<my:Property my:Name="Hint" my:Value="This page shows all active members, to change the assigments, click the Change Team Assignments tab above." />
</my:Properties>
</my:Control>
The WCF trace has the token already replaced:
Enumerate(/Person[stActiveAssignmentIDs = '0bca70d8-a0af-4548-922e-11b3d460788f']), Principal(7fb2b853-24f0-4498-9534-4e10589723c4)
I can only guess that the other controls do not include the logic to resolve the token properly if at all.Brad Turner, ILM MVP - Ensynch, Inc - www.identitychaos.com [If a post helps to resolve your issue, please click the "Mark as Answer" or "Helpful" button at the top of that post. By marking a post as Answered or Helpful, you help others
find the answer faster.]
Free Windows Admin Tool Kit Click here and download it now
November 5th, 2010 5:00pm
Brad - %ObjectID% worked fine for me, but %Attribute_xxx% resolves to the real XXX variable from RCDC form as stated in the docs.
The problem is that all reference values are stored as urn:uuid:objectid format. and that prefix urn:uuid goes to XPath query as is. Surely it must be removed from Xpath query to work.
the code to be modified is definetely this procedure: Microsoft.IdentityManagement.WebUI.UniversalObjectControl.Controls.UocTextBox.ReplaceXPathValue
November 6th, 2010 3:44am
it doesn't inspire much confidence when there's good evidence to suggest there's a bug in the product and nobody from Microsoft will reply to confirm. This needs to be addressed. Validation is a critical part of the data-entry process and one I'm struggling
with myself. It would be good to see someone from the product team step in and let us know what is and isn't the case and if these things are going to be addressed in an up-coming release.
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2010 11:53am
our TAM from MS is working on it.
November 18th, 2010 2:22pm
Great, let us know the outcome please :)
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2010 6:41am
Brad - %ObjectID% worked fine for me, but %Attribute_xxx% resolves to the real XXX variable from RCDC form as stated in the docs.
The problem is that all reference values are stored as urn:uuid:objectid format. and that prefix urn:uuid goes to XPath query as is. Surely it must be removed from Xpath query to work.
the code to be modified is definetely this procedure: Microsoft.IdentityManagement.WebUI.UniversalObjectControl.Controls.UocTextBox.ReplaceXPathValue
Yes, but which control are you using - the UocTextBox? Some of the controls behave differently. My point above is that if you were using the UocListView, then the references do resolve correctly, even without the urn:uuid: prefixes. UocIdentityPicker control
doesn't add the urn:uuid: prefix, it just doesn't resolve the reference at all! So, there are multiple bugs at play here depending upon the control you are using.Brad Turner, ILM MVP - Ensynch, Inc - www.identitychaos.com [If a post helps to resolve your issue, please click the "Mark as Answer" or "Helpful" button at the top of that post. By marking a post as Answered or Helpful, you help others
find the answer faster.]
November 19th, 2010 11:45am
Brad, you UocListView doesn't use UniquenesValidationXpath :)
other web controls that just simply query with %objectID% or %value% work perfect.
lets close this thread as I don't expect an answer from MS to this soon
Free Windows Admin Tool Kit Click here and download it now
November 20th, 2010 3:08am