protected override void GetItem(string path) { using (EnterContext(path)) { DirectoryEntryInfo info = GetEntryInfoFromPSPath(path); WriteEntryInfo(info); } }
public bool Equals(DirectoryEntryInfo other) { if (other == null) { return(false); } return(Entry.Path.Equals(other.Entry.Path, StringComparison.OrdinalIgnoreCase) && Entry.Username.Equals(other.Entry.Username, StringComparison.OrdinalIgnoreCase)); }
public bool Equals(DirectoryEntryInfo other) { if (other == null) { return false; } return Entry.Path.Equals(other.Entry.Path, StringComparison.OrdinalIgnoreCase) && Entry.Username.Equals(other.Entry.Username, StringComparison.OrdinalIgnoreCase); }
protected override bool IsItemContainer(string path) { using (EnterContext(path)) { using (DirectoryEntryInfo info = GetEntryInfoFromPSPath(path)) { return(info.IsContainer); } } }
public void GetProperty(string path, Collection <string> providerSpecificPickList) { using (EnterContext(path)) { using (DirectoryEntryInfo info = GetEntryInfoFromPSPath(path)) { PSObject properties = info.GetProperty(providerSpecificPickList, ParamRawSet); WritePropertyObject(properties, path); } } }
private void GetPathItems(DirectoryEntryInfo parent, bool recurse, bool nameOnly, ReturnContainers returnContainers) { foreach (DirectoryEntryInfo child in parent.GetChildren()) { WriteEntryInfo(child, nameOnly); if (recurse) { GetPathItems(child, recurse, nameOnly, returnContainers); } } }
protected override void NewItem(string path, string itemTypeName, object newItemValue) { using (EnterContext(path)) { string parentPath, childName; SplitPath(path, out parentPath, out childName); using (DirectoryEntry parent = GetEntryFromPSPath(parentPath)) { DirectoryEntry child = DirectoryEntryType.NewItem(parent, childName, itemTypeName); child.CommitChanges(); DirectoryEntryInfo info = GetEntryInfo(child); WriteEntryInfo(info); } } }
private void GetPathItems(string path, bool recurse, bool nameOnly, ReturnContainers returnContainers) { using (EnterContext(path)) { DirectoryEntryInfo parent = GetEntryInfoFromPSPath(path); if (parent.IsContainer) { using (parent) { GetPathItems(parent, recurse, nameOnly, returnContainers); } } else { WriteEntryInfo(parent, nameOnly); } } }
public void SetProperty(string path, PSObject value) { using (EnterContext(path)) { using (DirectoryEntryInfo info = GetEntryInfoFromPSPath(path)) { if (ParamAddSet) { info.AddPropertyValue(value, ParamRawSet); } else if (ParamRemoveSet) { info.RemovePropertyValue(value, ParamRawSet); } else { info.SetProperty(value, ParamRawSet); } } } }
private void WriteEntryInfo(DirectoryEntryInfo info, bool nameOnly) { try { object value = info; if (nameOnly) { value = info.Name; } WriteItemObject(value, info.FullName, info.IsContainer); } finally { if (nameOnly) { info.Dispose(); } } }
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)); } }
private string[] GetDistinguishedNames(object value) { DirectoryEntryInfo info = value as DirectoryEntryInfo; if (info != null) { return(new string[] { info.DistinguishedName }); } IEnumerable paths = (value as IEnumerable); if (value is string) { paths = new object[] { value }; } if (paths != null) { return(GetDistinguishedNames(paths)); } return(new string[0]); }
private string[] GetDistinguishedNames(IEnumerable paths) { List <PSObject> items = new List <PSObject>(); foreach (string p in paths) { items.AddRange(CurrentProvider.InvokeProvider.Item.Get(p)); } List <String> names = new List <string>(items.Count); foreach (PSObject itm in items) { using (DirectoryEntryInfo info = (itm.BaseObject as DirectoryEntryInfo)) { if (info != null) { names.Add(info.DistinguishedName); } } } return(names.ToArray()); }
private void WriteEntryInfo(DirectoryEntryInfo info) { WriteEntryInfo(info, false); }
protected DirectoryEntryInfo[] NewUsers(int count) { DirectoryEntryInfo[] users = new DirectoryEntryInfo[count]; for (int i = 0; i < count; i++) { users[i] = GetItem<DirectoryEntryInfo>(NewUser()); } return users; }