LogPortalObject() public static method

public static LogPortalObject ( string msg, string obj ) : void
msg string
obj string
return void
Ejemplo n.º 1
0
        private void DeletePortalGroup(Node node)
        {
            try
            {
                AdLog.LogPortalObject("Deleting portal group", node.Path);

                node.Delete();
            }
            catch (Exception ex)
            {
                AdLog.LogErrorADObject(ex.Message, node.Path);
            }
        }
Ejemplo n.º 2
0
        public void CreateNewADContainer(Node node, string newPath)
        {
            IUser originalUser = User.Current;

            Common.ChangeToAdminAccount();

            try
            {
                var parentPath = RepositoryPath.GetParentPath(newPath);

                // get containing synctree
                var syncTree = GetSyncTreeContainingPortalPath(newPath);
                if (syncTree == null)
                {
                    // not synced object
                    return;
                }
                AdLog.LogPortalObject("Creating new AD orgunit/group/container", node.Path);

                var parentADPath = syncTree.GetADPath(parentPath);

                // create new AD object
                var adObjType = Common.GetADObjectType(node.NodeType);
                switch (adObjType)
                {
                case ADObjectType.OrgUnit:
                    CreateADOrgUnit(syncTree, parentADPath, node);
                    break;

                case ADObjectType.Group:
                    CreateADGroup(syncTree, parentADPath, node);
                    break;

                case ADObjectType.Container:
                    CreateADContainer(syncTree, parentADPath, node);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                AdLog.LogException(ex);
                throw new Exception(ex.Message, ex);
            }
        }
Ejemplo n.º 3
0
        private void DeletePortalUser(Node node)
        {
            try
            {
                AdLog.LogPortalObject("Deleting (disabling) portal user", node.Path);

                ((IUser)node).Enabled = false;
                Common.DisablePortalUserCustomProperties(node, _propertyMappings);
                Common.UpdateLastSync(node, null);
                //node.Save(); - update lastsync already saves node

                Node.Move(node.Path, _deletedFromADPath);
            }
            catch (Exception ex)
            {
                AdLog.LogErrorADObject(ex.Message, node.Path);
            }
        }
Ejemplo n.º 4
0
        private void UpdateADObject(Node node, string newPath, string passwd, Action <DirectoryEntry, SyncTree, Node, string, string> UpdateObjectProperties)
        {
            // ha az objektum nincs szinkronizálva
            if (!IsSyncedObject(node.Path))
            {
                return;
            }

            // ha a mozgatás nem megengedett tartományok között történik
            if (!AllowMoveADObject(node, newPath))
            {
                return;
            }

            AdLog.LogPortalObject("Updating AD object", node.Path);

            var guid = Common.GetPortalObjectGuid(node);

            if (guid.HasValue)
            {
                var ADObject = GetADObjectByGuid((Guid)guid);
                using (DirectoryEntry entry = ADObject.entry)
                {
                    if (entry != null)
                    {
                        var entrySyncTree = ADObject.syncTree;
                        UpdateObjectProperties(entry, entrySyncTree, node, newPath, passwd);
                    }
                    else
                    {
                        AdLog.LogErrorPortalObject(string.Format("AD object with the given GUID ({0}) does not exist", guid.ToString()), node.Path);
                    }
                }
            }
            else
            {
                AdLog.LogErrorPortalObject("Portal node does not have a syncguid", node.Path);
            }
        }
Ejemplo n.º 5
0
        public void DeleteADObject(string nodePath, Guid?guid)
        {
            IUser originalUser = User.Current;

            Common.ChangeToAdminAccount();

            try
            {
                if (!IsSyncedObject(nodePath))
                {
                    return;
                }

                AdLog.LogPortalObject("Deleting AD object", nodePath);

                //var guid = Common.GetPortalObjectGuid(node);
                if (guid.HasValue)
                {
                    SyncTreeADObject ADObject = GetADObjectByGuid((Guid)guid);
                    using (DirectoryEntry entry = ADObject.entry)
                    {
                        if (entry != null)
                        {
                            // disable users under AD object and move them to specific folder
                            var  deletedPath  = ADObject.syncTree.DeletedADObjectsPath;
                            bool entryDeleted = false;
                            using (DirectoryEntry deletedParent = ADObject.syncTree.ConnectToObject(deletedPath))
                            {
                                using (SearchResultCollection resultColl = ADObject.syncTree.GetUsersUnderADObject(entry))
                                {
                                    foreach (SearchResult result in resultColl)
                                    {
                                        using (DirectoryEntry userEntry = result.GetDirectoryEntry())
                                        {
                                            var userPath = userEntry.Path;

                                            // disable user and move to deleted folder
                                            if (deletedParent != null)
                                            {
                                                userEntry.MoveTo(deletedParent);
                                            }
                                            else
                                            {
                                                AdLog.LogError("Folder for deleted users could not be found on AD server!");
                                            }

                                            Common.DisableUserAccount(userEntry);
                                            Common.DisableADObjectCustomProperties(userEntry, _propertyMappings, _config.ADNameMaxLength, _config.ADsAMAccountNameMaxLength);
                                            userEntry.CommitChanges();

                                            // ha a parent objektum maga egy user volt, akkor őt később már nem kell törölni
                                            if (entry.Path == userPath)
                                            {
                                                entryDeleted = true;
                                            }
                                        }
                                    }
                                }
                            }

                            // delete remaining entries under this entry including itself (if it has not been deleted yet)
                            if (!entryDeleted)
                            {
                                // double check user containment: if it still contains users, raise an error!
                                using (SearchResultCollection resultColl = ADObject.syncTree.GetUsersUnderADObject(entry))
                                {
                                    if (resultColl.Count == 0)
                                    {
                                        entry.DeleteTree();
                                    }
                                    else
                                    {
                                        AdLog.LogErrorADObject("AD container cannot be deleted, it contains users!", entry.Path);
                                    }
                                }
                            }
                        }
                        else
                        {
                            AdLog.LogErrorPortalObject(string.Format("AD object with the given GUID ({0}) does not exist", guid.ToString()), nodePath);
                        }
                    }
                }
                else
                {
                    AdLog.LogErrorPortalObject("Portal node does not have a syncguid", nodePath);
                }
            }
            catch (Exception ex)
            {
                AdLog.LogException(ex);
                throw new Exception(ex.Message, ex);
            }
        }