Exemplo n.º 1
0
        public static bool IsADObjectPathSynced(Guid guid, SyncTree syncTree)
        {
            // Check if the AD object corresponding to the given portal guid exists under any of the
            // synchronized trees - if not, it should be deleted from the portal.
            var adPath = syncTree.GetADPath(guid.ToString());

            if (!string.IsNullOrEmpty(adPath))
            {
                if (SyncConfiguration.Current.SyncTrees.Any(t => t.ContainsADPath(adPath)))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public static void DisablePortalUserCustomProperties(Content content, SyncTree syncTree)
        {
            content.Name = content.Name.PrefixDeleted();

            foreach (var propMapping in syncTree.Mappings)
            {
                foreach (var portalProp in propMapping.PortalProperties)
                {
                    if (!portalProp.Unique)
                    {
                        continue;
                    }

                    var propValue = GetContentValue(content, portalProp) ?? string.Empty;
                    var setValue  = propValue.PrefixDeleted();

                    SetContentValue(content, portalProp, setValue, ADObjectType.User);
                }
            }
        }
Exemplo n.º 3
0
 public static async Task <IEnumerable <Content> > QueryAllContent(ADObjectType objType, SyncTree syncTree, bool allFields = false)
 {
     return(await QueryContentByTypeAndPath(objType, syncTree.PortalPath.TrimEnd('/'), allFields?null : Common.Fields));
 }
Exemplo n.º 4
0
        public static void UpdatePortalUserCustomProperties(DirectoryEntry entry, dynamic content, SyncTree syncTree)
        {
            // sAMAccountName -> Name
            if (syncTree.Server.SyncUserName)
            {
                content.Name = entry.Properties[syncTree.UserNameProperty].Value.ToString();

                // in case of AD users the content name and login name are the same
                content.LoginName = content.Name;
            }

            // user actions
            foreach (var propMapping in syncTree.Mappings)
            {
                if (propMapping.AdProperties.Count == 1)
                {
                    if (propMapping.PortalProperties.Count == 1)
                    {
                        // 1 ADproperty + 1 portalproperty
                        var portalProp = propMapping.PortalProperties[0];
                        var adProp     = propMapping.AdProperties[0];
                        var adValue    = GetEntryValue(entry, adProp);
                        SetContentValue(content, portalProp, adValue, ADObjectType.User);

                        // Email is a special case: if it is empty, the user cannot be synced, at least we log it here.
                        if (string.CompareOrdinal(portalProp.Name, "Email") == 0 && string.IsNullOrEmpty(adValue))
                        {
                            AdLog.LogWarning("Email is empty for user " + entry.Path);
                        }
                    }
                    else
                    {
                        // 1 ADproperty + n portalproperty
                        // split AD value (preserving spaces) and put them into portal properties
                        var adProp   = propMapping.AdProperties[0];
                        var adValues = GetEntryValue(entry, adProp).Split(new[] { propMapping.Separator }, StringSplitOptions.None);
                        int index    = 0;
                        foreach (var portalProp in propMapping.PortalProperties)
                        {
                            var adValue = (index < adValues.Length) ? adValues[index] : null;
                            SetContentValue(content, portalProp, adValue, ADObjectType.User);
                            index++;
                        }
                    }
                }
                else
                {
                    // 1 portalproperty + n ADproperty
                    // concat AD property values and put it into the single portal property
                    var portalProp = propMapping.PortalProperties[0];
                    var adValue    = propMapping.ConcatAdPropValues(entry);
                    SetContentValue(content, portalProp, adValue, ADObjectType.User);
                }
            }
        }