Results 1 to 2 of 2

Thread: form authentication for sub folder

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    form authentication for sub folder

    Looking to make just one folder and all sub-folders within this folder to be password protected with form authentication. At this time, I have the following in my web.config file that works but it does for the whole site.
    I have a folder off the root called email that calls the Login.aspx file when not authenticated. Issue is that files off the root folder are calling /email/Login.aspx as well.

    Any thoughts?

    VB Code:
    1. <configuration>
    2.     <appSettings>
    3.         <add key="MM_CONNECTION_HANDLER_SQLServer" value="sqlserver.htm" />
    4.         <add key="MM_CONNECTION_STRING_SQLServer" value="Persist Security Info=False;Data Source=xx.xx.xx.xx;Initial Catalog=dbname;User ID=uid;Password=pwd" />
    5.         <add key="MM_CONNECTION_DATABASETYPE_SQLServer" value="SQLServer" />
    6.         <add key="MM_CONNECTION_SCHEMA_SQLServer" value="" />
    7.         <add key="MM_CONNECTION_CATALOG_SQLServer" value="" />
    8.         <add key="MS_SQL_CONN" value="Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=dbname" />
    9.     </appSettings>
    10.  
    11.     <system.web>
    12.         <authentication mode="Forms">
    13.             <forms loginUrl="/email/Login.aspx">
    14.                 <credentials passwordFormat="MD5">
    15.                     <user name="test" password="63E46DF4AC6DD41BFAA7CE7630D0533D" />
    16.                 </credentials>
    17.             </forms>
    18.         </authentication>
    19.         <authorization>
    20.             <deny users="?" />
    21.         </authorization>
    22.     </system.web>
    23. </configuration>

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: form authentication for sub folder

    Make the root of the website accessible to everybody and then setup a new location (in this case the email directory) and only allow access to authenticated users. You also need to give unauthorised access to the login page if it is in that directory otherwise you'll need to be logged in to log in which is a little silly. See below - give a shout if you need anything else or I've misinterpreted anything.

    Code:
    <configuration>
    	<appSettings>
    		<add key="MM_CONNECTION_HANDLER_SQLServer" value="sqlserver.htm" />
    		<add key="MM_CONNECTION_STRING_SQLServer" value="Persist Security Info=False;Data Source=xx.xx.xx.xx;Initial Catalog=dbname;User ID=uid;Password=pwd" />
    		<add key="MM_CONNECTION_DATABASETYPE_SQLServer" value="SQLServer" />
    		<add key="MM_CONNECTION_SCHEMA_SQLServer" value="" />
    		<add key="MM_CONNECTION_CATALOG_SQLServer" value="" />
    		<add key="MS_SQL_CONN" value="Server=xx.xx.xx.xx;uid=name;pwd=pwd;database=dbname" />
    	</appSettings>
    
    	<system.web>
    		<authentication mode="Forms">
    			<forms loginUrl="/email/Login.aspx">
    				<credentials passwordFormat="MD5">
    					<user name="test" password="63E46DF4AC6DD41BFAA7CE7630D0533D" />
    				</credentials>
    			</forms>
    		</authentication>
    		<authorization>
    			<allow users="*" />
    		</authorization>
    	</system.web>
    	
    	<location path="email">
            	<system.web>
                		<authorization>
                    		<deny users="?" />
                		</authorization>
            	</system.web>
        	</location>
    
    	<location path="email/login.aspx">
            	<system.web>
                		<authorization>
                    		<allow users="*" />
                		</authorization>
            	</system.web>
        	</location>
    </configuration>
    DJ

    If I have been helpful please rate my post. If I haven't tell me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width