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:
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
bool IsAttributeAvailable(CSEntry csentry, string AttribName)
{
try
{
return(csentry[AttribName].IsPresent);
}
catch(AttributeNotInInclusionListException ex)
{
return(false);
}
}
Send comments about this topic to Microsoft
Build date: 2/16/2009