public Uid Create(ObjectClass objectClass, ICollection <ConnectorAttribute> createAttributes, OperationOptions options) { ConnectorAttributesAccessor accessor = new ConnectorAttributesAccessor(createAttributes); if (accessor.HasAttribute("fail")) { throw new ConnectorException("Test Exception"); } else if (accessor.HasAttribute("exist") && accessor.FindBoolean("exist") == true) { throw new AlreadyExistsException(accessor.GetName().GetNameValue()); } else if (accessor.HasAttribute("emails")) { object value = ConnectorAttributeUtil.GetSingleValue(accessor.Find("emails")); if (value is IDictionary) { return(new Uid((string)((IDictionary)value)["email"])); } else { throw new InvalidAttributeValueException("Expecting Map"); } } return(new Uid(_config.Guid.ToString())); }
public virtual Uid Update(ObjectClass objectClass, Uid uid, ICollection <ConnectorAttribute> replaceAttributes, OperationOptions options) { var attributesAccessor = new ConnectorAttributesAccessor(replaceAttributes); Name newName = attributesAccessor.GetName(); Uid uidAfterUpdate = uid; if (newName != null) { Trace.TraceInformation("Rename the object {0}:{1} to {2}", objectClass.GetObjectClassValue(), uid.GetUidValue(), newName.GetNameValue()); uidAfterUpdate = new Uid(newName.GetNameValue().ToLower()); } if (ObjectClass.ACCOUNT.Equals(objectClass)) { } else if (ObjectClass.GROUP.Is(objectClass.GetObjectClassValue())) { if (attributesAccessor.HasAttribute("members")) { throw new InvalidAttributeValueException("Requested to update a read only attribute"); } } else { Trace.TraceWarning("Update of type {0} is not supported", _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(), objectClass.GetObjectClassValue())); throw new NotSupportedException("Update of type" + objectClass.GetObjectClassValue() + " is not supported"); } return(uidAfterUpdate); }