Пример #1
0
        /// <summary>
        /// Provision the site based on the provisioning manifest in a file
        /// </summary>
        /// <param name="statusLogs">Store status logs here</param>
        /// <param name="pathSecrets">Where the log in secrets are</param>
        /// <param name="pathProvisioningManifest">Where the provisioning steps are</param>
        /// <param name="outputPath">Where output files go</param>
        private void ProvisionFromFileManifest(TaskStatusLogs statusLogs, string pathSecrets, string pathProvisioningManifest, string outputPath)
        {
            //Load the config from the files
            var secretsConfig = new ProvisionConfigSiteAccess(pathSecrets);

            //Load the user provisioning instructions
            var provisionUsersInfo = new ProvisionUserInstructions(
                pathProvisioningManifest);

            var provisionSite = new ProvisionSite(secretsConfig, provisionUsersInfo, this, statusLogs);

            provisionSite.Execute();

            //---------------------------------------------------------------------
            //Generate an output file
            //---------------------------------------------------------------------
            FileIOHelper.CreatePathIfNeeded(outputPath);

            var outputFilePath = Path.Combine(outputPath, "ProvisionSiteOutput.csv");

            provisionSite.CSVResultsReport.GenerateCSVFile(outputFilePath);

            statusLogs.AddStatusHeader("Done!");
            ((IShowLogs)this).NewLogResultsToShow(statusLogs);
        }
    /// <summary>
    /// Output the site membership block
    /// </summary>
    /// <param name="xmlWriter"></param>
    private void WriteProvisioningManifestXml_SiteMembership(XmlWriter xmlWriter, ProvisionConfigExternalDirectorySync provisionConfig)
    {
        xmlWriter.WriteStartElement("SiteMembership");

        //--------------------------------------------------------------------------------
        //Write the provisioning instructions into the XML
        //--------------------------------------------------------------------------------
        //Modify existing users?
        //1.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authDefaultExistingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForExistingDefaultAuthUsers));
        //2.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authSamlExistingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForExistingSamlUsers));
        //3.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authOpenIdExistingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForExistingOpenIdUsers));


        //Modify missing users
        //1.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authDefaultMissingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForMissingDefaultAuthUsers));
        //2.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authSamlMissingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForMissingSamlUsers));
        //3.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authOpenIdMissingUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForMissingOpenIdUsers));

        //Unlicese unexptected users
        //1.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authDefaultUnexpectedUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForUnexpectedDefaultAuthUsers));
        //2.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authSamlUnexpectedUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForUnexpectedSamlUsers));
        //3.
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_authOpenIdUnexpectedUsers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForUnexpectedOpenIdUsers));

        //Write out all the users
        RolesManager.WriteUserRolesAsXml(xmlWriter);

        xmlWriter.WriteEndElement();
    }
Пример #3
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="config"></param>
    /// <param name="provisionInstructions"></param>
    /// <param name="showLogsHere"></param>
    /// <param name="statusLogs"></param>
    public ProvisionSite(ProvisionConfigSiteAccess config, ProvisionUserInstructions provisionInstructions, IShowLogs showLogsHere, TaskStatusLogs statusLogs)
    {
        _showLogsHere          = showLogsHere;
        _config                = config;
        _provisionInstructions = provisionInstructions;

        if (statusLogs == null)
        {
            statusLogs = new TaskStatusLogs();
        }
        _statusLogs = statusLogs;
    }
    /// <summary>
    /// Output the groups membership block
    /// </summary>
    /// <param name="xmlWriter"></param>
    private void WriteProvisioningManifestXml_GroupsMembership(XmlWriter xmlWriter, ProvisionConfigExternalDirectorySync provisionConfig)
    {
        xmlWriter.WriteStartElement("GroupsMemberships");

        //--------------------------------------------------------------------------------
        //Write the provisioning instructions into the XML
        //--------------------------------------------------------------------------------
        //Missing group members?
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_MissingGroupMembers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForGroupMisingMembers));

        //Unexpected group members?
        xmlWriter.WriteAttributeString(
            ProvisionUserInstructions.XmlAttribute_UnexpectedGroupMembers,
            ProvisionUserInstructions.XmlAttributeText(provisionConfig.ActionForGroupUnexpectedMembers));

        //Write out all the groups
        GroupsMembershipManager.WriteUserGroupsAsXml(xmlWriter);

        xmlWriter.WriteEndElement();
    }
Пример #5
0
/// <summary>
/// CONSTRUCTOR
/// </summary>
/// <param name="filePathConfig"></param>
    public ProvisionConfigExternalDirectorySync(string filePathConfig)
    {
        //==================================================================================
        //Load values from the TARGET SITE config file
        //==================================================================================
        var xmlConfig = new System.Xml.XmlDocument();

        xmlConfig.Load(filePathConfig);

        //-------------------------------------------------------------------------------
        //Get any special instructions for email mapping
        //-------------------------------------------------------------------------------
        var xnodeHeader = xmlConfig.SelectSingleNode("//SynchronizeConfiguration");

        this.EmailMapping = ParseUserEmailMapping(
            XmlHelper.SafeParseXmlAttribute(xnodeHeader, XmlAttribute_UserEmailMapping, ""));



        var xnodeRoleSyncHeader = xmlConfig.SelectSingleNode("//SynchronizeConfiguration/SynchronizeRoles");

        //-------------------------------------------------------------------------------
        //Get instructions about the intended site membership provisioning
        //-------------------------------------------------------------------------------
        //UNEXPECTED USERS
        //1.
        this.ActionForUnexpectedSamlUsers = ProvisionUserInstructions.ParseUnexpectedUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authSamlUnexpectedUsers);
        //2.
        this.ActionForUnexpectedDefaultAuthUsers = ProvisionUserInstructions.ParseUnexpectedUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authDefaultUnexpectedUsers);
        //3.
        this.ActionForUnexpectedOpenIdUsers = ProvisionUserInstructions.ParseUnexpectedUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authOpenIdUnexpectedUsers);

        //MISSING USERS
        //1.
        this.ActionForMissingSamlUsers = ProvisionUserInstructions.ParseMissingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authSamlMissingUsers);
        //2.
        this.ActionForMissingDefaultAuthUsers = ProvisionUserInstructions.ParseMissingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authDefaultMissingUsers);
        //3.
        this.ActionForMissingOpenIdUsers = ProvisionUserInstructions.ParseMissingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authOpenIdMissingUsers);

        //EXISTING USERS
        //1.
        this.ActionForExistingSamlUsers = ProvisionUserInstructions.ParseExistingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authSamlExistingUsers);
        //2.
        this.ActionForExistingDefaultAuthUsers = ProvisionUserInstructions.ParseExistingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authDefaultExistingUsers);
        //3.
        this.ActionForExistingOpenIdUsers = ProvisionUserInstructions.ParseExistingUserActionFromAttribute(
            xnodeRoleSyncHeader, ProvisionUserInstructions.XmlAttribute_authOpenIdExistingUsers);


        //-------------------------------------------------------------------------------
        //Get instructions about the intended group membership provisioning
        //-------------------------------------------------------------------------------
        var xnodeGroupsSyncHeader = xmlConfig.SelectSingleNode("//SynchronizeConfiguration/SynchronizeGroups");

        this.ActionForGroupMisingMembers = ProvisionUserInstructions.ParseMissingGroupMemberAction(
            xnodeGroupsSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_MissingGroupMembers].Value);

        this.ActionForGroupUnexpectedMembers = ProvisionUserInstructions.ParseUnexpectedGroupMemberAction(
            xnodeGroupsSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_UnexpectedGroupMembers].Value);


        //---------------------------------------------------------------------------------------------
        //Load the list User/Role mapping groups we want to look up in the external directory
        //---------------------------------------------------------------------------------------------
        this.GroupsToRolesSyncList = ParseGroupsToRoles(xmlConfig).AsReadOnly();


        //--------------------------------------------------------------------------------------
        //Load any user/role overrides that may be defined for the site
        //--------------------------------------------------------------------------------------
        this.UserRolesOverrideList = ProvisionUserInstructions.ParseUsers(
            xmlConfig,
            "//SynchronizeConfiguration/SynchronizeRoles/SiteMembershipOverrides/User",
            "**OVERRIDE**").AsReadOnly();

        //---------------------------------------------------------------------------------------------
        //Load the list of group/group mappings we want to look up in the external directory
        //---------------------------------------------------------------------------------------------
        List <ISynchronizeGroupToGroup> groupsToSync = new List <ISynchronizeGroupToGroup>();

        //1. Load and add explicit group/group mappings
        groupsToSync.AddRange(ParseGroupsToGroups(xmlConfig));
        //2. Load and add pattern matching group/group mappings
        groupsToSync.AddRange(ParsePatternMatchGroupsToGroups(xmlConfig));

        this.GroupsToGroupsSyncList = groupsToSync.AsReadOnly();
    }
Пример #6
0
    /// <summary>
    /// CONSTRUCTOR
    /// </summary>
    /// <param name="filePathConfig"></param>
    public ProvisionConfigExternalDirectorySync(string filePathConfig)
    {
        //==================================================================================
        //Load values from the TARGET SITE config file
        //==================================================================================
        var xmlConfig = new System.Xml.XmlDocument();

        xmlConfig.Load(filePathConfig);

        var xnodeRoleSyncHeader = xmlConfig.SelectSingleNode("//SynchronizeConfiguration/SynchronizeRoles");

        //-------------------------------------------------------------------------------
        //Get instructions about the intended site membership provisioning
        //-------------------------------------------------------------------------------
        this.ActionForUnexpectedSamlUsers = ProvisionUserInstructions.ParseUnexpectedUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authSamlUnexpectedUsers].Value);

        this.ActionForUnexpectedDefaultAuthUsers = ProvisionUserInstructions.ParseUnexpectedUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authDefaultUnexpectedUsers].Value);

        this.ActionForMissingSamlUsers = ProvisionUserInstructions.ParseMissingUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authSamlMissingUsers].Value);

        this.ActionForMissingDefaultAuthUsers = ProvisionUserInstructions.ParseMissingUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authDefaultMissingUsers].Value);

        this.ActionForExistingSamlUsers = ProvisionUserInstructions.ParseExistingUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authSamlExistingUsers].Value);

        this.ActionForExistingDefaultAuthUsers = ProvisionUserInstructions.ParseExistingUserAction(
            xnodeRoleSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_authDefaultExistingUsers].Value);


        //-------------------------------------------------------------------------------
        //Get instructions about the intended group membership provisioning
        //-------------------------------------------------------------------------------
        var xnodeGroupsSyncHeader = xmlConfig.SelectSingleNode("//SynchronizeConfiguration/SynchronizeGroups");

        this.ActionForGroupMisingMembers = ProvisionUserInstructions.ParseMissingGroupMemberAction(
            xnodeGroupsSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_MissingGroupMembers].Value);

        this.ActionForGroupUnexpectedMembers = ProvisionUserInstructions.ParseUnexpectedGroupMemberAction(
            xnodeGroupsSyncHeader.Attributes[ProvisionUserInstructions.XmlAttribute_UnexpectedGroupMembers].Value);


        //---------------------------------------------------------------------------------------------
        //Load the list User/Role mapping groups we want to look up in the external directory
        //---------------------------------------------------------------------------------------------
        this.GroupsToRolesSyncList = ParseGroupsToRoles(xmlConfig).AsReadOnly();


        //--------------------------------------------------------------------------------------
        //Load any user/role overrides that may be defined for the site
        //--------------------------------------------------------------------------------------
        this.UserRolesOverrideList = ProvisionUserInstructions.ParseUsers(
            xmlConfig,
            "//SynchronizeConfiguration/SynchronizeRoles/SiteMembershipOverrides/User",
            "**OVERRIDE**").AsReadOnly();

        //---------------------------------------------------------------------------------------------
        //Load the list of group/group mappings we want to look up in the external directory
        //---------------------------------------------------------------------------------------------
        this.GroupsToGroupsSyncList = ParseGroupsToGroups(xmlConfig).AsReadOnly();
    }