Request property email validation

I’m using request properties in the new web portal to create and update objects in AD. I’m able to do most of what I need, except validation of email addresses. I have simplified the parameter set a lot in this example, but this is basically what I’m trying to do:

The parameter set have two parameters, AccProduct and Mail, both user selectable.

The AccProduct parameter contains a drop down from the AccProducts table, filtered on AccProucts which are connected to ADSGroup-objects with email addresses. When a element is chosen in this list, the OnPropertyChangedScript populates the Mail-property with the email address of the related ADSGroup.
 

If Value Is Nothing Then
	ParameterSet("Mail").Value = ""
Else
	Dim f As ISqlFormatter = Session.SqlFormatter
	Dim uidADSGroup = Connection.GetSingleProperty("ADSGroup", "UID_ADSGroup", f.UIDComparison("UID_AccProduct", Convert.ToString(Value)))
	Dim dbADSGroup = Session.Source.Get("ADSGroup", uidADSGroup)

	ParameterSet("Mail").Value = dbADSGroup.GetValue("Mail").String
End If

The Mail parameter is a normal input field where the user can change the email address populated from AccProduct. In this property I have a ValidationScript that checks if the email address is unused.

Dim f As ISqlFormatter = Session.SqlFormatter

If Value IsNot Nothing AndAlso ParameterSet("AccProduct").HasValue Then
	' Get new email address
	Dim newMail As String = Convert.ToString(Value)
	
	' Get original orgIdent address from ADSGroup
	Dim adsMail As String = Connection.GetSingleProperty("ADSGroup", "Mail", f.UIDComparison("UID_AccProduct", ParameterSet("AccProduct").Value.ToString))

	' Check mail if changed
	If newMail <> adsMail Then
		If CCC_IsEmailAddressInUse(newMail) Then
			Throw New VIException("Email address " & newMail & " is in use", ExceptionRelevance.EndUser)
		End If
	End If
End If

In the script I must retrieve the current email address and only validate if it is changed, else the validation will fail since the address is in use by itself.

The problem is the following: The user selects an item from the AccProduct-list and the email is populated and validation skipped (newMail = adsMail). If the user then selects another AccProduct, it seems like AccProduct.OnPropertyChangedScript is triggered and populates ParameterSet("Mail").Value. Then the Mail.ValidationScript contains the new email address in the “Value”-variable, but ParameterSet("AccProduct").Value still contains reference to the previous AccProduct. The result is that newMail and adsMail is not equal, the InUse-check runs, and exception is thrown.

Are there any way to either run the validation-script when the user manually inputs text, or make sure that the new value of ParameterSet("AccProduct").Value is used in the ValidationScript?

 

I don’t find the documentation to be clear about the difference between the three script-types (ValueScript, ValidationScript and OnPropertyChangedScript), in what order they are excecuted and what properties are available. My guess is that OnPropertyChangedScript replicates Table OnSaving-Script and are triggered every time the property is changed (since this is a save to the database), ValueScript is like Column Template and ValidationScript is similar to Column Formatting Script. Maybe someone have a better explanation?

I'm using One Identity Manager 9.1.1 and the Angular/HTML5 Web Portal

  • I found a way around the problem with a little hack:

    The OnPropertyChangedScript on the AccProduct-parameter:

    If Value Is Nothing Then
    	ParameterSet("Mail").Value = ""
    Else
    	Dim f As ISqlFormatter = Session.SqlFormatter
    	Dim uidADSGroup = Connection.GetSingleProperty("ADSGroup", "UID_ADSGroup", f.UIDComparison("UID_AccProduct", Convert.ToString(Value)))
    	Dim dbADSGroup = Session.Source.Get("ADSGroup", uidADSGroup)
    	
    	' Hack to skip email verification when pushing email address from ADSGroup
    	Dim mail As String = String.Format("{0}{1}", dbADSGroup.GetValue("Mail").String, "|inherited from AccProduct")
    	ParameterSet("Mail").Value = mail
    End If

    The ValidationScript on the Mail-parameter:

    Dim f As ISqlFormatter = Session.SqlFormatter
    
    If Value IsNot Nothing Then
    	' Verify manually entered email address
    	If Not Convert.ToString(Value).Contains("|inherited from AccProduct") Then
    		' Get new email address
    		Dim newMail As String = Convert.ToString(Value)
    		
    		' Get original orgIdent address from ADSGroup
    		Dim adsMail As String = Connection.GetSingleProperty("ADSGroup", "Mail", f.UIDComparison("UID_AccProduct", ParameterSet("AccProduct").Value.ToString))
    	
    		' Check mail if changed
    		If newMail <> adsMail Then
    			If CCC_IsEmailAddressInUse(newMail) Then
    				Throw New VIException("Email address " & newMail & " is in use", ExceptionRelevance.EndUser)
    			End If
    		End If
    	
    	' Skip verification if inherited from AccProduct
    	Else 
    		Value = Convert.ToString(Value).Replace("|inherited from AccProduct","")
    	End If
    End If

    As you can see, I added a text string to the email address when populated from AccProduct, and then checked for precense of this string in the ValidationString. If anyone have a cleaner solution, please let me know.

    I still don't fully understand the difference between the three scripts in regards of when they are executed, which parameters/variables are available, which parameters can be set, and so on. Are there anyone from OneIdentity that can explain this a bit deeper than available in the documentation (Identity Manager 9.2 - IT Shop Administration Guide)