예제 #1
0
        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);
        }
예제 #2
0
 public virtual SyncToken GetLatestSyncToken(ObjectClass objectClass)
 {
     if (ObjectClass.ACCOUNT.Equals(objectClass))
     {
         return(new SyncToken(10));
     }
     Trace.TraceWarning("Sync of type {0} is not supported",
                        _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                objectClass.GetObjectClassValue()));
     throw new NotSupportedException("Sync of type" + objectClass.GetObjectClassValue() + " is not supported");
 }
예제 #3
0
 public virtual Uid ResolveUsername(ObjectClass objectClass, string userName, OperationOptions options)
 {
     if (ObjectClass.ACCOUNT.Equals(objectClass))
     {
         return(new Uid(userName));
     }
     Trace.TraceWarning("ResolveUsername of type {0} is not supported",
                        _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                objectClass.GetObjectClassValue()));
     throw new NotSupportedException("ResolveUsername of type" + objectClass.GetObjectClassValue() +
                                     " is not supported");
 }
예제 #4
0
 public virtual void Delete(ObjectClass objectClass, Uid uid, OperationOptions options)
 {
     if (ObjectClass.ACCOUNT.Equals(objectClass) || ObjectClass.GROUP.Equals(objectClass))
     {
         // do real delete here
     }
     else
     {
         Trace.TraceWarning("Delete of type {0} is not supported",
                            _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                    objectClass.GetObjectClassValue()));
         throw new NotSupportedException("Delete of type" + objectClass.GetObjectClassValue() +
                                         " is not supported");
     }
 }
예제 #5
0
 public virtual Uid Create(ObjectClass objectClass, ICollection <ConnectorAttribute> createAttributes,
                           OperationOptions options)
 {
     if (ObjectClass.ACCOUNT.Equals(objectClass) || ObjectClass.GROUP.Equals(objectClass))
     {
         Name name = ConnectorAttributeUtil.GetNameFromAttributes(createAttributes);
         if (name != null)
         {
             // do real create here
             return(new Uid(ConnectorAttributeUtil.GetStringValue(name).ToLower()));
         }
         throw new InvalidAttributeValueException("Name attribute is required");
     }
     Trace.TraceWarning("Delete of type {0} is not supported",
                        _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                objectClass.GetObjectClassValue()));
     throw new NotSupportedException("Delete of type" + objectClass.GetObjectClassValue() + " is not supported");
 }
예제 #6
0
        public virtual void Sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler,
                                 OperationOptions options)
        {
            if (ObjectClass.ALL.Equals(objectClass))
            {
                //
            }
            else if (ObjectClass.ACCOUNT.Equals(objectClass))
            {
                var builder = new ConnectorObjectBuilder();
                builder.SetUid("3f50eca0-f5e9-11e3-a3ac-0800200c9a66");
                builder.SetName("Foo");
                builder.AddAttribute(ConnectorAttributeBuilder.BuildEnabled(true));

                var deltaBuilder = new SyncDeltaBuilder
                {
                    Object    = builder.Build(),
                    DeltaType = SyncDeltaType.CREATE,
                    Token     = new SyncToken(10)
                };

                foreach (SyncDelta connectorObject in CollectionUtil.NewSet(deltaBuilder.Build()))
                {
                    if (!handler.Handle(connectorObject))
                    {
                        // Stop iterating because the handler stopped processing
                        break;
                    }
                }
            }
            else
            {
                Trace.TraceWarning("Sync of type {0} is not supported",
                                   _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                           objectClass.GetObjectClassValue()));
                throw new NotSupportedException("Sync of type" + objectClass.GetObjectClassValue() + " is not supported");
            }
            ((SyncTokenResultsHandler)handler).HandleResult(new SyncToken(10));
        }