Beispiel #1
0
        public static void SetEntryValue(DirectoryEntry entry, SyncProperty adProp, string value)
        {
            var propValue   = value.MaximizeLength(adProp.MaxLength);
            var propValColl = entry.Properties[adProp.Name];

            // ha törlünk egy propertyt portálon, akkor AD-ban ne csak a valuet töröljük, hanem a propertyt magát
            // különben constraint errort kapunk
            // removeat: single-valued properties, clear: multi-valued properties
            if (string.IsNullOrEmpty(propValue))
            {
                // ha nincs besettelve AD-ban a property, és portálról sem nyúlunk hozzá, akkor ne csináljunk semmit
                if (propValColl.Count == 0)
                {
                    return;
                }
                // single valued property
                if (propValColl.Count == 1)
                {
                    propValColl.RemoveAt(0);
                    return;
                }
                // multi valued property
                propValColl.Clear();
                return;
            }

            // setting the value null clears the collection
            propValColl.Value = null;

            // setting the value to propValue adds propValue to the collection
            propValColl.Value = propValue;
        }
Beispiel #2
0
        public static string GetEntryValue(DirectoryEntry entry, SyncProperty adProp)
        {
            var propValColl = entry.Properties[adProp.Name];

            if (propValColl == null)
            {
                return(string.Empty);
            }

            string value = null;

            if (propValColl.Count >= 1)
            {
                value = propValColl[0] as string;
            }
            return(value ?? string.Empty);
        }
Beispiel #3
0
        public static void SetNodeValue(Node node, SyncProperty portalProp, string value)
        {
            var propValue = value.MaximizeLength(portalProp.MaxLength);

            switch (portalProp.Name)
            {
            case "Name":
                node.Name = propValue;
                break;

            default:
                if (node.HasProperty(portalProp.Name))
                {
                    node[portalProp.Name] = propValue;
                }
                else
                {
                    // log: nincs ilyen property
                }
                break;
            }
        }
Beispiel #4
0
        public static string GetNodeValue(Node node, SyncProperty portalProp)
        {
            if (node.HasProperty(portalProp.Name))
            {
                var propValue = node[portalProp.Name];
                if (propValue == null)
                {
                    return(null);
                }
                return(propValue.ToString());
            }

            switch (portalProp.Name)
            {
            case "Name":
                return(node.Name);

            default:
                // log: nincs ilyen property
                return(null);
            }
        }