ConvertAdAttributesToExchange() static private method

Finds the attributes in connector object and rename it according to input array of names, but only if the atribute name is in attributes to get
If some of the params is null
static private ConvertAdAttributesToExchange ( ConnectorObject cobject ) : ConnectorObject
cobject Org.IdentityConnectors.Framework.Common.Objects.ConnectorObject ConnectorObject which attributes should be replaced
return Org.IdentityConnectors.Framework.Common.Objects.ConnectorObject
Ejemplo n.º 1
0
        public void Sync(SyncOpContext context)
        {
            ExchangeConnector        exconn = (ExchangeConnector)context.Connector;
            ActiveDirectoryConnector adconn = exconn.ActiveDirectoryConnector;

            ICollection <string> attsToGet = null;

            if (context.Options != null && context.Options.AttributesToGet != null)
            {
                attsToGet = CollectionUtil.NewSet(context.Options.AttributesToGet);
            }

            // delegate to get the exchange attributes if requested
            SyncResultsHandler xchangeHandler = new SyncResultsHandler()
            {
                Handle = delta =>
                {
                    if (delta.DeltaType == SyncDeltaType.DELETE)
                    {
                        return(context.SyncResultsHandler.Handle(delta));
                    }

                    // replace the ad attributes with exchange ones and add recipient type and database (if requested)
                    ConnectorObject updated = ExchangeUtility.ConvertAdAttributesToExchange(delta.Object);
                    //updated = this.AddExchangeAttributes(exconn, context.ObjectClass, updated, attsToGet);
                    if (updated != delta.Object)
                    {
                        // build new sync delta, cause we changed the object
                        SyncDeltaBuilder deltaBuilder = new SyncDeltaBuilder
                        {
                            DeltaType = delta.DeltaType,
                            Token     = delta.Token,
                            Uid       = delta.Uid,
                            Object    = updated
                        };
                        delta = deltaBuilder.Build();
                    }

                    return(context.SyncResultsHandler.Handle(delta));
                }
            };

            // call AD sync, use xchangeHandler
            adconn.SyncInternal(context.ObjectClass,
                                context.SyncToken, xchangeHandler, context.Options,
                                GetAdAttributesToReturn(adconn, context.ObjectClass, context.Options));
        }
Ejemplo n.º 2
0
        public void ExecuteQuery(ExecuteQueryContext context)
        {
            ExchangeConnector        exconn = (ExchangeConnector)context.Connector;
            ActiveDirectoryConnector adconn = exconn.ActiveDirectoryConnector;

            ICollection <string> attsToGet = null;

            if (context.Options != null && context.Options.AttributesToGet != null)
            {
                attsToGet = CollectionUtil.NewList(context.Options.AttributesToGet);
            }

            // delegate to get the exchange attributes if requested
            ResultsHandler filter = new SearchResultsHandler()
            {
                Handle = cobject =>
                {
                    LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Object returned from AD connector: {0}", CommonUtils.DumpConnectorAttributes(cobject.GetAttributes()));
                    ConnectorObject filtered = ExchangeUtility.ConvertAdAttributesToExchange(cobject);
                    //filtered = AddExchangeAttributes(exconn, context.ObjectClass, filtered, attsToGet);
                    LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Object as passed from Exchange connector: {0}", CommonUtils.DumpConnectorAttributes(filtered.GetAttributes()));
                    return(context.ResultsHandler.Handle(filtered));
                },

                HandleResult = result =>
                {
                    if (context.ResultsHandler is SearchResultsHandler)
                    {
                        ((SearchResultsHandler)context.ResultsHandler).HandleResult(result);
                    }
                }
            };

            ResultsHandler   handler2use = filter;
            OperationOptions options2use = context.Options;

            // mapping AttributesToGet from Exchange to AD "language"
            // actually, we don't need this code any more, because there are no attribute that are not retrieved by default
            // Uncomment this code if necessary in the future.
            if (context.Options != null && context.Options.AttributesToGet != null)
            {
                /*
                 * ISet<string> mappedExchangeAttributesToGet = new HashSet<string>(AttMap2AD.Keys);
                 * mappedExchangeAttributesToGet.IntersectWith(options.AttributesToGet);
                 * if (mappedExchangeAttributesToGet.Count > 0 || attsToGet.Contains(AttRecipientType))
                 * {
                 *  // replace Exchange attributes with AD names
                 *  var newAttsToGet = ExchangeUtility.FilterReplace(attsToGet, AttMap2AD);
                 *
                 *  // we have to remove recipient type, as it is unknown to AD
                 *  newAttsToGet.Remove(AttRecipientType);
                 *
                 *  // build new op options
                 *  var builder = new OperationOptionsBuilder(options);
                 *  string[] attributesToGet = new string[newAttsToGet.Count];
                 *  newAttsToGet.CopyTo(attributesToGet, 0);
                 *  builder.AttributesToGet = attributesToGet;
                 *  options2use = builder.Build();
                 * } */

                /*
                 * if (attsToGet.Contains(ExchangeConnectorAttributes.AttDatabase))
                 * {
                 *  attsToGet.Remove(ExchangeConnectorAttributes.AttDatabase);
                 *
                 *  // build new op options
                 *  var builder = new OperationOptionsBuilder(context.Options);
                 *  string[] attributesToGet = new string[attsToGet.Count];
                 *  attsToGet.CopyTo(attributesToGet, 0);
                 *  builder.AttributesToGet = attributesToGet;
                 *  options2use = builder.Build();
                 * }
                 */
            }

            adconn.ExecuteQueryInternal(context.ObjectClass,
                                        context.Query, handler2use, options2use,
                                        GetAdAttributesToReturn(adconn, context.ObjectClass, context.Options));
        }