コード例 #1
0
        /// <summary>
        /// this method is called by SAF.Authentication is create an principal object
        /// for a given user and application name
        /// </summary>
        /// <param name="userid">user id</param>
        /// <param name="applicationName">application name</param>
        public ADPrincipal(SAFIdentity safIdentity)
        {
            identity = safIdentity;
            ConfigurationManager cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            XmlNode providerData    = cm.AuthenticationConfig.GetProviderConfigurationData(safIdentity.ApplicationName);

            //retrieve ADSI query string used to search for the given user.
            searchQuery = providerData.SelectSingleNode("ADDirectoryEntry").InnerText;
        }
コード例 #2
0
        /// <summary>
        /// constructor takes the SAFIdentity as its parameter.
        /// </summary>
        /// <param name="sid">SAFIdentity object which contain the identity and appplication name information</param>
        public SAFPrincipal(SAFIdentity sid)
        {
            //retrieve the authentication configuraiton from the configuraiton file
            ConfigurationManager        cm = (ConfigurationManager)ConfigurationSettings.GetConfig("Framework");
            AuthenticationConfiguration ac = cm.AuthenticationConfig;

            //set identity object and the SAFUser property
            identity = sid;
            safUser  = ac.GetSAFUserName(sid.Name, sid.ApplicationName);
            //set the application inforamtion of the SAFPrincipal
            SetApplication(sid.ApplicationName);
        }
コード例 #3
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;
        }