Example #1
0
        /*=========================================================================== Async pattern */
        private static void ProcessAction(ActionType actionType, Node node, string newPath, string passWd)
        {
            var adAction = new ADAction(actionType, node, newPath, passWd);

            // no immediate background async action executed
            // -> user of app pool cannot have elevated AD rights
            var syncPortal2AD = new SyncPortal2AD();

            if (syncPortal2AD.IsSyncedObject(node.Path))
            {
                SaveAction(adAction, null);
            }
        }
Example #2
0
        /*=========================================================================== Async pattern */
        private static void ProcessAction(ActionType actionType, Node node, string newPath, string passWd)
        {
            var adAction = new ADAction(actionType, node, newPath, passWd);

            // no immediate background async action executed
            // -> user of app pool cannot have elevated AD rights
            var      syncPortal2AD = new SyncPortal2AD();
            SyncTree syncTree;

            if (syncPortal2AD.IsSyncedObject(node.Path, out syncTree))
            {
                if (node.NodeType.IsInstaceOfOrDerivedFrom("Group") && !syncTree.SyncGroups)
                {
                    return;
                }

                SaveAction(adAction, null);
            }
        }
Example #3
0
        private static void SaveAction(ADAction adAction, File origFile)
        {
            // serialize this object and save it to a node
            var serializer = new XmlSerializer(typeof(ADAction));

            // serialize password?
            var config = Portal2ADConfiguration.Current;

            if (!config.SaveFailedPassword)
            {
                adAction.PassWd = null;
            }

            //save the action in elevated mode
            using (new SystemAccount())
            {
                Common.EnsurePath(_actionPath);

                var failFile = origFile;
                if (failFile == null)
                {
                    failFile = new File(Node.LoadNode(_actionPath));
                    var fileName = string.Format(_actionName, Guid.NewGuid().ToString());
                    failFile.Name = fileName;
                }

                using (System.IO.Stream inputStream = new System.IO.MemoryStream())
                {
                    using (System.IO.TextWriter writer = new System.IO.StreamWriter(inputStream))
                    {
                        serializer.Serialize(writer, adAction);
                        writer.Flush();

                        failFile.Binary.SetStream(inputStream);
                        failFile.Save();
                    }
                }
            }
        }