الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أحتاج مساعدة في ادارة الموقع بواسطه ال Authentication

بدأه FUNCTION في 9 أبريل 2009 · 0 رد · 644 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1

:blush:

السلام عليكــم ورحمـة الله وبركاتــه

،،بســم الله الـرحمــن الرحيــم

الحمدلله والصلاة والسلام على رسول الله وعلى آله وصحبه أجمعين

انا بصراحة عند بناء موقعي للتجارب .. لم اكن على علم بهذه الامور وهي الـ authentication والرول ..

فعملت لوحة تحكم للادمن..

وكل الصفحات للادمن وهي لوحة التحكم واراثة من الماستر بيج للادمن..

والصفحات العادية للزوار .. مثل الرئيسية - اتصل بنا - سجل الزوار - من نحن .. والصفحات العادية لعرض المواضيع..

طبعا كنت استخدم في تسجيل الدخول لوحة التحكم السشن . وكان السشن ينتهي بسرعة .. واعلم انه السشن ليس هو الحل الصحيح لعمل لوحة تحكم.. لكي يدخلها فقط الادمن..

وبعد اطلاعي على عدة مواضيع لاحظت انه . authentication هو الحل الانسب لهذا الشيء ..

وقرات كذلك انه تقدر تحط مجلد وفيه صفحات الي تبيهم فقط يدخلهم الادمن المصرح له..

فانا محتار هل في طريقة انه تحدد وتقول انه الصفحات الي تبع الماستر بيج هذي للادمن محد يقدر يعرضها الا .. الادمن ؟ من خلال الـ authentication او لازم احطهم في مجلد. ؟ لكي تسهل العملية ؟

طبعا هذا هو ملف الويب كونفق اتمنى التعديل عليه .. طبعا انا اتمنى انه نقدر نستخدم الكوكيز يعني نفس طريقة المنتدى بالضبط ..

<?xml version="1.0"?>
<!-- 
	Note: As an alternative to hand editing this file you can use the 
	web admin tool to configure settings for your application. Use
	the Website->Asp.Net Configuration option in Visual Studio.
	A full list of settings and comments can be found in 
	machine.config.comments usually located in 
	\Windows\Microsoft.Net\Framework\v2.x\Config 
-->

<configuration>

	<configSections>
		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				</sectionGroup>
			</sectionGroup>
		</sectionGroup>
	</configSections>
  <appSettings>
	<add key="ConnectionString" value="provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|community_services.mdb;"/>
  </appSettings>
	<connectionStrings/>
	<system.web>


	<sessionState mode ="InProc" cookieless ="true" timeout ="60" >  
	</sessionState>

		<!-- 
			Set compilation debug="true" to insert debugging 
			symbols into the compiled page. Because this 
			affects performance, set this value to true only 
			during development.
		-->
		<compilation debug="true">
			<assemblies>
				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
			</assemblies>

	  <!--I think the license file is not copied to your server.

	  Read this:
	  If you use the publish web site feature of Visual Studio 2005/2008
	  you may have noticed that some files are not copied in your deployment
	  and that you have to copy them manually. For example license files - 
	  if you have .lic or .licx files in your project that have to be deployed along 
	  with your project and you use publish web site you'll notice that they do not get copied
	  To fix this just add this to to the compilation section of your web.config:
	  ali jassim albasri 13 March 2009 11:56 PM-->
	  <buildProviders>
		<remove extension=".lic"/>
		<add extension=".lic"
			type="System.Web.Compilation.ForceCopyBuildProvider"/>
	  </buildProviders>
		</compilation>
		<!--
			The <authentication> section enables configuration 
			of the security authentication mode used by 
			ASP.NET to identify an incoming user. 
		-->
		<authentication mode="Forms"/>

			<!--The <customErrors> section enables configuration 
			of what to do if/when an unhandled error occurs 
			during the execution of a request. Specifically, 
			it enables developers to configure html error pages 
			to be displayed in place of a error stack trace.-->

	<customErrors mode="Off"></customErrors>


	<pages>
			<controls>
				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			</controls>
		</pages>
		<httpHandlers>
			<remove verb="*" path="*.asmx"/>
			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
		</httpHandlers>
		<httpModules>
			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
		</httpModules>




	</system.web>
	<system.codedom>
		<compilers>
			<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
				<providerOption name="CompilerVersion" value="v3.5"/>
				<providerOption name="WarnAsError" value="false"/>
			</compiler>
			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
				<providerOption name="CompilerVersion" value="v3.5"/>
				<providerOption name="OptionInfer" value="true"/>
				<providerOption name="WarnAsError" value="false"/>
			</compiler>
		</compilers>
	</system.codedom>
	<!-- 
		The system.webServer section is required for running ASP.NET AJAX under Internet
		Information Services 7.0.  It is not necessary for previous version of IIS.
	-->
	<system.webServer>
		<validation validateIntegratedModeConfiguration="false"/>
	<modules>
	  <add name="CuteEditor.UploadModule" type="CuteEditor.UploadModule,CuteEditor"/>
	</modules>
		<modules>
			<remove name="ScriptModule"/>
			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
		</modules>
		<handlers>
			<remove name="WebServiceHandlerFactory-Integrated"/>
			<remove name="ScriptHandlerFactory"/>
			<remove name="ScriptHandlerFactoryAppServices"/>
			<remove name="ScriptResource"/>
			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
		</handlers>
	</system.webServer>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
			</dependentAssembly>
		</assemblyBinding>
	</runtime>
</configuration>

وهذه صفحة الون انق واسمها : login.aspx داخل مجلد اسمه admin طبعا فيها شيك بوكس لحفظ كلمه المرور

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_login_admin : System.Web.UI.UserControl
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	protected void btn_login_Click(object sender, EventArgs e)
	{
		DatabaseManager dbm = new DatabaseManager();
		//String SQLs = "Select * from tbl_admin where User_Name='" + txt_User.Text + "'and Password='" + txt_pass.Text + "'";
		String SQLs = "Select * from tbl_admin where User_Name='" + txt_User.Text.Replace("'", "''") + "'and Password='" + txt_pass.Text.Replace("'", "''") + "'";
		DataSet ds = dbm.ExecuteStatement (SQLs);

		if (ds.Tables[0].Rows.Count > 0)
		{




			Session["User_Name"] = ds.Tables[0].Rows[0]["User_Name"].ToString();
			Session["ID_User"] = ds.Tables[0].Rows[0]["ID_User"].ToString();

			// Then GO to Control Panel Of User
			Response.Redirect("..//ControlPanel.aspx");
			dbm.ClearParameters();


		}
		else
		{
			Label1.Visible = true;
		}
	}
}

فاتمنى الحول من الخبراء .. اذا كان الحل اني اضع كل صفحات لوحة التحكم في مجلد . راح يسهل الامر .. راح اسويه ..

وواذا عادي فاتمى المساعدة ..

اتمنى التعديل على الكود من حيث وضع الااثتنكيشن .. والله يجزيكم الجنه .. في الدنيا والآخره ...

تحياتي لكم :wub:

مواضيع مشابهة