예제 #1
0
 public DirectoryRootInfo(string protocol, string server, ushort port, LdapPath path)
 {
     _protocol = protocol;
     _server   = server;
     _port     = port;
     _path     = path;
 }
예제 #2
0
        internal string GetEntryPSPath(DirectoryEntry entry)
        {
            LdapPath path = LdapPath.Parse(DirectoryUtils.GetDistinguishedName(entry));

            foreach (DirectoryServiceDriveInfo drive in ProviderInfo.Drives)
            {
                if (path.IsChildOf(drive.RootInfo.Path))
                {
                    return(NormalizeSlashes(drive.Name + ":\\" + path.GetChildPart().ToCanonicalName(false)));
                }
            }

            return(NormalizeSlashes(ProviderInfo.PSSnapIn.Name + '\\' + ProviderInfo.Name + "::" + entry.Path));
        }
예제 #3
0
        private void ParsePSPath(string path, out DirectoryRootInfo root, out string childPath)
        {
            foreach (DirectoryServiceDriveInfo drive in ProviderInfo.Drives)
            {
                if (path.StartsWith(drive.Root, StringComparison.OrdinalIgnoreCase))
                {
                    root      = drive.RootInfo;
                    childPath = path.Substring(drive.Root.Length);
                    childPath = childPath.Trim(Slash, Backslash);

                    return;
                }
            }

            string protocol = DSProtocol.GetProtocol(ref path);

            string server = null;
            ushort port   = DSProtocol.DefaultPort;

            int slash = path.IndexOfAny(new char[] { Slash, Backslash });

            if (slash > -1)
            {
                server = path.Substring(0, slash);
                path   = path.Substring(slash + 1);

                int colon = server.IndexOf(':');

                if (colon > -1)
                {
                    port   = ushort.Parse(server.Substring(colon + 1));
                    server = server.Substring(0, colon);
                }
            }

            slash = path.IndexOfAny(new char[] { Slash, Backslash });

            if (slash < 0)
            {
                slash = path.Length;
            }

            Utils.SplitString(path, slash, out path, out childPath);

            root = new DirectoryRootInfo(protocol, server, port, LdapPath.Parse(path));
        }
예제 #4
0
 public DirectoryRootInfo(string protocol, LdapPath path)
     : this(protocol, null, 0, path)
 {
 }