GetPortalParentPath() публичный Метод

public GetPortalParentPath ( string objectADPath ) : string
objectADPath string
Результат string
Пример #1
0
        /// <summary>
        /// Gets portal info for given LDAP path. If resulting SyncInfo object's SyncTreeFound is false, no other properties are filled.
        /// </summary>
        /// <param name="ldapPath">The LDAP path of the object, ie. CN=MyGroup,OU=MyOrg,DC=Nativ,DC=local</param>
        /// <returns></returns>
        public SyncInfo GetSyncInfo(string ldapPath)
        {
            SyncInfo result = new SyncInfo();

            SyncTree syncTree = null;

            foreach (SyncTree sTree in _syncTrees)
            {
                if (sTree.ContainsADPath(ldapPath))
                {
                    syncTree = sTree;
                }
            }

            if (syncTree == null)
            {
                return(result);
            }

            result.SyncTreeFound       = true;
            result.SyncTreeADPath      = syncTree.ADPath;
            result.SyncTreePortalPath  = syncTree.PortalPath;
            result.SyncTreeADIPAddress = syncTree.IPAddress;
            result.TargetPortalPath    = syncTree.GetPortalPath(ldapPath);
            result.PortalNodeExists    = string.IsNullOrEmpty(result.TargetPortalPath) ? false : Node.Exists(result.TargetPortalPath);
            var parentPath = syncTree.GetPortalParentPath(ldapPath);

            result.PortalParentExists = string.IsNullOrEmpty(parentPath) ? false : Node.Exists(parentPath);

            return(result);
        }
Пример #2
0
        // sync objects from AD to portal
        private void SyncObjectsFromAD(SyncTree syncTree,
                                       ADObjectType objType,
                                       SearchResultCollection allADObjects,
                                       Action <DirectoryEntry, string, Guid, SyncTree> CreateNewObject,
                                       Action <DirectoryEntry, Node, SyncTree> UpdateProperties)
        {
            foreach (SearchResult result in allADObjects)
            {
                try
                {
                    string nodeADpath = result.Path;

                    if (syncTree.IsADPathExcluded(nodeADpath))
                    {
                        continue;
                    }

                    AdLog.LogOuterADObject("Syncing", result.Path);

                    var guid = Common.GetADResultGuid(result, _config.GuidProp);

                    if (!guid.HasValue)
                    {
                        // no AD guid present for object
                        AdLog.LogErrorADObject("No AD GUID present", result.Path);
                        continue;
                    }

                    // új objektumok (ou, user, group) felvétele, átmozgatások
                    // - ha létezik az adott guid-ú objektum -> path ellenőrzés, átmozgatás
                    // - ha nem létezik, létrehozás

                    string nodePortalParentPath = syncTree.GetPortalParentPath(nodeADpath);
                    if (!Node.Exists(nodePortalParentPath))
                    {
                        // adpath: OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
                        // portalParentPath: "/Root/IMS/NATIV/ExampleOrg"
                        EnsurePortalPath(syncTree, syncTree.GetADParentObjectPath(result.Path), RepositoryPath.GetParentPath(nodePortalParentPath));
                    }

                    SyncOneADObject(result, null,
                                    (Guid)guid,
                                    objType,
                                    nodePortalParentPath,
                                    CreateNewObject,
                                    UpdateProperties,
                                    syncTree);
                }
                catch (Exception ex)
                {
                    // syncing of one object of the current tree failed
                    AdLog.LogException(ex);
                }
            }
        }
Пример #3
0
        // sync objects from AD to portal
        private void SyncObjectsFromAD(SyncTree syncTree,
            ADObjectType objType,
            SearchResultCollection allADObjects,
            Action<DirectoryEntry, string, Guid, SyncTree> CreateNewObject,
            Action<DirectoryEntry, Node, SyncTree> UpdateProperties)
        {
            foreach (SearchResult result in allADObjects)
            {
                try
                {
                    string nodeADpath = result.Path;

                    if (syncTree.IsADPathExcluded(nodeADpath))
                        continue;

                    AdLog.LogOuterADObject("Syncing", result.Path);

                    var guid = Common.GetADResultGuid(result, _config.GuidProp);

                    if (!guid.HasValue)
                    {
                        // no AD guid present for object
                        AdLog.LogErrorADObject("No AD GUID present", result.Path);
                        continue;
                    }

                    // új objektumok (ou, user, group) felvétele, átmozgatások
                    // - ha létezik az adott guid-ú objektum -> path ellenőrzés, átmozgatás
                    // - ha nem létezik, létrehozás

                    string nodePortalParentPath = syncTree.GetPortalParentPath(nodeADpath);
                    if (!Node.Exists(nodePortalParentPath))
                    {
                        // adpath: OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
                        // portalParentPath: "/Root/IMS/NATIV/ExampleOrg"
                        EnsurePortalPath(syncTree, syncTree.GetADParentObjectPath(result.Path), RepositoryPath.GetParentPath(nodePortalParentPath));
                    }

                    SyncOneADObject(result, null,
                        (Guid)guid,
                        objType,
                        nodePortalParentPath,
                        CreateNewObject,
                        UpdateProperties,
                        syncTree);
                }
                catch (Exception ex)
                {
                    // syncing of one object of the current tree failed
                    AdLog.LogException(ex);
                }
            }
        }
Пример #4
0
        private void SyncSingleObjectFromAD(string ldapPath)
        {
            SyncTree       syncTree = null;
            DirectoryEntry entry    = null;

            foreach (SyncTree sTree in _syncTrees)
            {
                if (sTree.ContainsADPath(ldapPath))
                {
                    entry    = sTree.ConnectToObject(ldapPath);
                    syncTree = sTree;
                }
            }

            if (syncTree == null)
            {
                AdLog.LogErrorADObject("Configured SyncTree could not be found for this path", ldapPath);
                return;
            }

            string nodePortalParentPath = syncTree.GetPortalParentPath(ldapPath);

            if (!Node.Exists(nodePortalParentPath))
            {
                AdLog.LogErrorADObject(string.Format("Portal parent path ({0}) does not exist", nodePortalParentPath), ldapPath);
                return;
            }

            if (entry == null)
            {
                AdLog.LogErrorADObject("AD Entry is not found", ldapPath);
                return;
            }

            var guid = Common.GetADObjectGuid(entry, _config.GuidProp);

            if (!guid.HasValue)
            {
                AdLog.LogErrorADObject("AD Entry guid cannot be retrieved", ldapPath);
                return;
            }

            var adObjectType = Common.GetADObjectType(entry, false);
            Action <DirectoryEntry, string, Guid, SyncTree> CreateNewObject  = null;
            Action <DirectoryEntry, Node, SyncTree>         UpdateProperties = null;

            switch (adObjectType)
            {
            case ADObjectType.User:
                CreateNewObject  = CreateNewPortalUser;
                UpdateProperties = UpdatePortalUserProperties;
                break;

            case ADObjectType.Group:
                CreateNewObject  = CreateNewPortalGroup;
                UpdateProperties = UpdatePortalGroupProperties;
                break;

            case ADObjectType.Container:
            case ADObjectType.Organization:
            case ADObjectType.OrgUnit:
                CreateNewObject  = CreateNewPortalContainer;
                UpdateProperties = UpdatePortalContainerProperties;
                break;

            default:
                AdLog.LogErrorADObject("Syncing of this type is not supported.", ldapPath);
                return;
            }

            // check if node already exists:
            var node = Common.GetPortalObjectByGuid(guid.Value);

            if (node == null)
            {
                if (!Node.Exists(nodePortalParentPath))
                {
                    EnsurePortalPath(syncTree, syncTree.GetADParentObjectPath(ldapPath), RepositoryPath.GetParentPath(nodePortalParentPath));
                }

                CreateNewObject(entry, nodePortalParentPath, guid.Value, syncTree);
            }
            else
            {
                if (RepositoryPath.GetParentPath(node.Path) != nodePortalParentPath)
                {
                    Node.Move(node.Path, nodePortalParentPath);

                    // reload node for further processing (set properties)
                    node = Node.LoadNode(node.Id);
                }

                UpdateProperties(entry, node, syncTree);
                Common.UpdateLastSync(node, null);
            }
        }