Microsoft Identity Integration Server 2003 Developer Reference

Example: Checking for Existing Attributes

Your provisioning method will throw an exception if you attempt to access an attribute that was not selected in the attribute inclusion list. This topic demonstrates one technique to avoid this problem.

The following example shows how to catch the exception that is raised when attempting to access an attribute that was not included in the attribute inclusion list:

[Visual Basic .NET]
Public Function IsAttributeAvailable(ByVal csentry As CSEntry, ByVal AttribName As String) As Boolean
 
Try
  IsAttributeAvailable = csentry(AttribName).IsPresent
Catch ex As AttributeNotInInclusionListException
  IsAttributeAvailable = False
End Try
 
End Function
[C#]
bool IsAttributeAvailable(CSEntry csentry, string AttribName)
{
  try
  {
	return(csentry[AttribName].IsPresent);
  }
  catch(AttributeNotInInclusionListException ex)
  {
	return(false);
  }
}