Esempio n. 1
0
        private static IList <IOrganization> InitAncestorOUsByParentID(IOguObject current)
        {
            List <IOrganization> result = new List <IOrganization>();

            string parentID = current.Properties.GetValue("PARENT_GUID", string.Empty);

            while (parentID.IsNotEmpty())
            {
                OguObjectCollection <IOrganization> parents =
                    OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.Guid, parentID);

                if (parents.Count > 0)
                {
                    result.Insert(0, parents[0]);
                    current  = parents[0];
                    parentID = current.Properties.GetValue("PARENT_GUID", string.Empty);
                }
                else
                {
                    break;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private IOrganization GetTopOUFromMapping(string mappedPath)
        {
            IOrganization dept = null;

            if (this.fullPath.IndexOf(mappedPath, StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (ObjectType == SchemaType.Organizations)
                {
                    dept = (IOrganization)this;
                }
                else
                {
                    dept = this.Parent;
                }

                while (dept != null)
                {
                    if (string.Compare(dept.FullPath, mappedPath, true) == 0)
                    {
                        break;
                    }

                    dept = dept.Parent;
                }
            }
            else
            {
                OguObjectCollection <IOrganization> objs = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(
                    SearchOUIDType.FullPath,
                    mappedPath);

                ExceptionHelper.FalseThrow(objs.Count > 0, Resource.CanNotFindObject, mappedPath);

                dept = objs[0];
            }

            return(dept);
        }
Esempio n. 3
0
        private static IList <IOrganization> InitAncestorOUsByFullPath(IOguObject current)
        {
            string[] allFullPath = GetAncestorsFullPath(current.FullPath);

            List <IOrganization> result = null;

            if (allFullPath.Length > 0)
            {
                OguObjectCollection <IOrganization> organizations = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(
                    SearchOUIDType.FullPath,
                    allFullPath);

                organizations.Sort(OrderByPropertyType.FullPath, SortDirectionType.Ascending);

                result = organizations.ToList();
            }
            else
            {
                result = new List <IOrganization>();
            }

            return(result);
        }