StripADName() public static method

public static StripADName ( string name ) : string
name string
return string
Exemplo n.º 1
0
        public string GetPortalPath(string objectADPath)
        {
            // objectADPath e.g.: LDAP://192.168.0.75/OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
            // ADPath e.g.: "OU=ExampleOrg,DC=Nativ,DC=Local"
            // PortalPath e.g.: "/Root/IMS/ExampleOrg"

            if (!this.ContainsADPath(objectADPath))
            {
                return(null);
            }

            // trim serverpath from beginning
            string path = objectADPath;

            if (path.StartsWith(ServerPath))
            {
                path = path.Substring(ServerPath.Length, path.Length - this.ServerPath.Length); // OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
            }
            // trim adpath from end
            path = path.Substring(0, path.Length - this.ADPath.Length); // OU=OtherOrg,

            string[] directories      = path.Split(new string[] { "OU=", "CN=", "ou=", "cn=" }, StringSplitOptions.RemoveEmptyEntries);
            string   objectPortalPath = string.Empty;

            foreach (string dir in directories)
            {
                objectPortalPath = RepositoryPath.Combine(Common.StripADName(dir), objectPortalPath);
            }

            // e.g.: /Root/IMS/ExampleOrg/OtherOrg
            var objectPath = RepositoryPath.Combine(this.PortalPath, objectPortalPath).TrimEnd(new char[] { '/' });

            return(objectPath);
        }
Exemplo n.º 2
0
 // gets the object name from the name as it comes from AD (ie: ExampleOrg from OU=ExampleOrg)
 public static string GetADObjectName(string name)
 {
     // name e.g.: "OU=ExampleOrg"
     return(Common.StripADName(name.Substring(name.IndexOf("=") + 1)));
 }