Beispiel #1
0
        protected void AddProperty(DirectoryEntryProperty property)
        {
            if (_properties == null)
            {
                throw new InvalidOperationException();
            }

            property.Entry = _currentEntry;
            _properties.Add(property);
        }
Beispiel #2
0
        protected void AddProperty(DirectoryEntryProperty property)
        {
            if (_properties == null)
            {
                throw new InvalidOperationException();
            }

            property.Entry = _currentEntry; 
            _properties.Add(property);
        }
Beispiel #3
0
        private object ConvertToPropertyType(DirectoryEntryProperty targetProperty, object source)
        {
            if (targetProperty is IDistinguishedNameProperty)
            {
                string[] dns = GetDistinguishedNames(source);

                if (dns.Length == 1)
                {
                    return dns[0];
                }

                return dns;
            }

            return source;
        }
Beispiel #4
0
        private void AddItemProperty(PSObject retval, DirectoryEntryProperty dep)
        {
            if (dep.CanRead)
            {
                string name = dep.Name;
                object value = dep.GetValue();

                if (dep is IDistinguishedNameProperty)
                {
                    String stringValue = value as String;
                    ICollection listValue = value as ICollection;

                    if (listValue != null)
                    {
                        List<DirectoryEntryInfo> infoList = new List<DirectoryEntryInfo>();

                        foreach (string dn in listValue)
                        {
                            DirectoryEntry entry = CurrentProvider.GetEntry(dn);
                            DirectoryEntryInfo info = CurrentProvider.GetEntryInfo(entry);

                            infoList.Add(info);
                        }

                        value = infoList;
                    }
                    else if(stringValue != null)
                    {
                        DirectoryEntry entry = CurrentProvider.GetEntry(stringValue);
                        DirectoryEntryInfo info = CurrentProvider.GetEntryInfo(entry);

                        value = info;
                    }
                }

                retval.Members.Add(new PSNoteProperty(name, value));
            }
        }