public Guid GetObjectId(ADObjectFilterOptions options) { Guid principalId; if (options != null && options.Id != null && Guid.TryParse(options.Id, out principalId)) { // do nothing, we have parsed the guid } else { PSADObject adObj = GetADObject(options); if (adObj == null) { throw new KeyNotFoundException("The provided information does not map to an AD object id."); } principalId = adObj.Id; } return principalId; }