コード例 #1
0
        /// <summary>
        /// SetApplication will change the application context of principal object
        /// so that principal object represents the user membership information of
        /// a given application
        /// </summary>
        /// <param name="application">name of the application for which SAFPrincipal will switch the its membership information.</param>
        public void SetApplication(string application)
        {
            ConfigurationManager        cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            AuthenticationConfiguration ac = cm.AuthenticationConfig;
            //retrieve the type informatioin for the principal object of a given applicaiton
            string      typeName    = ac.GetPrincipalTypeForApplication(application);
            string      appUserName = cm.AuthenticationConfig.GetIdentityForApplicaiton(safUser, application);
            SAFIdentity safIdentity = new SAFIdentity(appUserName, application);
            Type        type        = Type.GetType(typeName);

            object[] parameters = new object[1] {
                safIdentity
            };
            //set the new object to the internal principal object.
            currentApplicationPrincipal = (IPrincipal)Activator.CreateInstance(type, parameters);
            identity = (IIdentity)safIdentity;
        }