GetADObjectNameFromPath() public static method

public static GetADObjectNameFromPath ( string portalPath ) : string
portalPath string
return string
Exemplo n.º 1
0
        public string GetADPath(string objectPortalPath)
        {
            // objectPortalPath e.g.: /Root/IMS/ExampleOrg/OtherOrg
            // ADPath e.g.: "OU=ExampleOrg,DC=Nativ,DC=Local"
            // PortalPath e.g.: "/Root/IMS/ExampleOrg"

            if (!this.ContainsPortalPath(objectPortalPath))
            {
                return(null);
            }

            string path = objectPortalPath.Substring(PortalPath.Length).Trim(new char[] { '/' }); // /OtherOrg/MyOrg

            // go through path elements and add them one-by-one to the output path
            string actPortalPath = PortalPath;
            string actADPath     = ADPath;

            foreach (string pathPart in path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries))
            {
                actPortalPath = RepositoryPath.Combine(actPortalPath, pathPart);
                var adObjName = Common.GetADObjectNameFromPath(actPortalPath);
                actADPath = Common.CombineADPath(actADPath, adObjName);
            }

            // e.g.: OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=Local
            return(actADPath);
        }