Exemple #1
0
        /// <summary>
        /// Obtain Authentication settings from database
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public Configuration()
        {
            mADSIPath = Path.GC;

            //Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
            Authentication.Configuration authConfig = Authentication.Configuration.GetConfig();
            mPortalId = authConfig.PortalId;

            try
            {
                //Temporary fix this setting as TRUE for design, to be removed when release
                mConfigDomainPath   = authConfig.RootDomain;
                mDefaultEmailDomain = authConfig.EmailDomain;
                mUserName           = authConfig.UserName;
                mPassword           = authConfig.Password;
                mAuthenticationType = (AuthenticationTypes)(@Enum.Parse(typeof(AuthenticationTypes), authConfig.AuthenticationType.ToString()));
                // IMPORTANT: Remove ADSIPath, to be added later depends on accessing method

                this.mRootDomainPath = Utilities.ValidateDomainPath(this.mConfigDomainPath, Path.GC);
                mRootDomainPath      = mRootDomainPath.Substring(mRootDomainPath.Length - mRootDomainPath.Length - mRootDomainPath.IndexOf("DC="), mRootDomainPath.Length - mRootDomainPath.IndexOf("DC="));
            }
            catch (Exception exc)
            {
                mProcessLog += exc.Message + "<br>";
            }

            // Also check if Authentication implemented in this Windows Network
            DirectoryEntry gc = new DirectoryEntry();

            try
            {
                if (DirectoryEntry.Exists("GC://rootDSE"))
                {
                    DirectoryEntry rootGC;
                    if ((mUserName.Length > 0) && (mPassword.Length > 0))
                    {
                        rootGC = new DirectoryEntry("GC://rootDSE", mUserName, mPassword, mAuthenticationType);
                    }
                    else
                    {
                        rootGC = new DirectoryEntry("GC://rootDSE");
                    }
                    mConfigurationPath = rootGC.Properties[ADSI_CONFIGURATIONNAMIMGCONTEXT].Value.ToString();
                    mADSINetwork       = true;
                }
            }
            catch (COMException exc)
            {
                mADSINetwork   = false;
                mLDAPAccesible = false;
                mProcessLog   += exc.Message + "<br>";
                Exceptions.LogException(exc);
                // Nothing to do if we could not access Global Catalog, so return
                return;
            }

            // Also check if LDAP fully accessible
            DirectoryEntry ldap = new DirectoryEntry();

            try
            {
                if (DirectoryEntry.Exists("LDAP://rootDSE"))
                {
                    mLDAPAccesible = true;
                    mRefCollection = new CrossReferenceCollection(mUserName, mPassword, mAuthenticationType);
                }
            }
            catch (COMException exc)
            {
                mLDAPAccesible = false;
                mProcessLog   += exc.Message + "<br>";
                Exceptions.LogException(exc);
            }
        }
        /// <summary>
        /// Obtain Authentication settings from database
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public Configuration()
        {
            mADSIPath = Path.GC;

            //Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
            Authentication.Configuration authConfig = Authentication.Configuration.GetConfig();
            mPortalId = authConfig.PortalId;

            try
            {
                //Temporary fix this setting as TRUE for design, to be removed when release
                mConfigDomainPath = authConfig.RootDomain;
                mDefaultEmailDomain = authConfig.EmailDomain;
                mUserName = authConfig.UserName;
                mPassword = authConfig.Password;
                mAuthenticationType = (AuthenticationTypes)( @Enum.Parse( typeof( AuthenticationTypes ), authConfig.AuthenticationType.ToString() ) );
                // IMPORTANT: Remove ADSIPath, to be added later depends on accessing method

                this.mRootDomainPath = Utilities.ValidateDomainPath( this.mConfigDomainPath, Path.GC );
                mRootDomainPath = mRootDomainPath.Substring( mRootDomainPath.Length - mRootDomainPath.Length - mRootDomainPath.IndexOf( "DC=" ), mRootDomainPath.Length - mRootDomainPath.IndexOf( "DC=" ) );
            }
            catch( Exception exc )
            {
                mProcessLog += exc.Message + "<br>";
            }

            // Also check if Authentication implemented in this Windows Network
            DirectoryEntry gc = new DirectoryEntry();
            try
            {
                if( DirectoryEntry.Exists( "GC://rootDSE" ) )
                {
                    DirectoryEntry rootGC;
                    if( ( mUserName.Length > 0 ) && ( mPassword.Length > 0 ) )
                    {
                        rootGC = new DirectoryEntry( "GC://rootDSE", mUserName, mPassword, mAuthenticationType );
                    }
                    else
                    {
                        rootGC = new DirectoryEntry( "GC://rootDSE" );
                    }
                    mConfigurationPath = rootGC.Properties[ADSI_CONFIGURATIONNAMIMGCONTEXT].Value.ToString();
                    mADSINetwork = true;
                }
            }
            catch( COMException exc )
            {
                mADSINetwork = false;
                mLDAPAccesible = false;
                mProcessLog += exc.Message + "<br>";
                Exceptions.LogException( exc );
                // Nothing to do if we could not access Global Catalog, so return
                return;
            }

            // Also check if LDAP fully accessible
            DirectoryEntry ldap = new DirectoryEntry();
            try
            {
                if( DirectoryEntry.Exists( "LDAP://rootDSE" ) )
                {
                    mLDAPAccesible = true;
                    mRefCollection = new CrossReferenceCollection( mUserName, mPassword, mAuthenticationType );
                }
            }
            catch( COMException exc )
            {
                mLDAPAccesible = false;
                mProcessLog += exc.Message + "<br>";
                Exceptions.LogException( exc );
            }
        }