Windows Authentication



\tDoes anybody know how to access windows nt user's credentials in an ASP program
\tI want to find out the role, user group of an user who logs in to the system. I don't know how to use windowsprincipal.isinrole.
Please help.
Posted On: Wednesday 2nd of January 2013 02:29:45 AM Total Views:  361
View Complete with Replies

RELATED TOPICS OF ASP.NET PROGRAMMING LANGUAGE




Parameterizing a generic object for stored procedure

I'm trying to reinforce our data lookups against sql injection and trying to maintain the original code as much as possible. Currently it appears that the procedure is passed a generic object as the set of parameters. I was wondering how I could perametize the words contained in the object like the example used on msdn(http://msdn.microsoft.com/en-us/library/ff648339.aspx) to protect against harmful injections. Any ideas using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet userDataset = new DataSet(); SqlDataAdapter myCommand = new SqlDataAdapter( "LoginStoredProcedure", connection); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; myCommand.SelectCommand.Parameters.Add("@au_id", SqlDbType.VarChar, 11); myCommand.SelectCommand.Parameters["@au_id"].Value = SSN.Text; myCommand.Fill(userDataset); } OUR current code: Public Function GetLookupList(ByVal LookupList As LookupLists, Optional ByVal objParms() As Object = Nothing) As DataTable Dim blnConnExists As Boolean = False Dim DS As New DataSet OpenConnection(_Db, blnConnExists) If System.Web.HttpContext.Current.Trace.IsEnabled Then System.Web.HttpContext.Current.Trace.Write("DataLookup", "Begin Get DataSet") If Not IsNothing(objParms) Then ' ensure that the query strings do not have nonbreaking spaces () ' if present, replace with standard spaces ( ) For i As Integer = 0 To objParms.Length - 1 If (GetType(String) Is objParms(i).GetType) Then objParms(i) = objParms(i).Replace(Chr(160), Chr(32)) End If Next DS = _Db.ExecuteDataSet("dbo." & LookupList.ToString, objParms) Else DS = _Db.ExecuteDataSet("dbo." & LookupList.ToString) If System.Web.HttpContext.Current.Trace.IsEnabled Then System.Web.HttpContext.Current.Trace.Write("DataLookup", "End Get DataSet") Return DS.Tables(0) End Function
VIEWS ON THIS POST

212

Posted on:

Friday 23rd November 2012
View Replies!

ASPC# Theme

I made three themes including the skin and css files. to change this theme you are redirected to another page with a drop down list and a Buton for selection. How do i redirect the selection back to the default page by using the button I don't know if it's a string or what. I have already built the website and everything. I know i have to do a [pre init] but on which pages code, but i don't know how to redirect the 2nd page selection to change the theme of the first page with the ddl's selection. I can't afford to buy a C# Book right now. (tmies are hard)Help. Default Page: Favorite Link Manager Enter Favorite: Folder Name Link: Default.CS: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void btnCreateFolder_Click(object sender, EventArgs e) { TreeNode xTN = new TreeNode(); if (tvTree.SelectedNode == null) { lblAnswer.Text = "Nothing Selected"; return; } { xTN.Text = txtBoxFolderName.Text; xTN.NavigateUrl = ""; xTN.Target = "_blank"; tvTree.SelectedNode.ChildNodes.Add(xTN); } } protected void btnAddFavorite_Click(object sender, EventArgs e) { TreeNode xFN = new TreeNode(); { xFN.Text = txtBoxEnterFav.Text; xFN.NavigateUrl = "txtBoxLink.Text"; xFN.Target = "_blank"; tvTree.SelectedNode.ChildNodes.Add(xFN); } } protected void btnChooseTheme_Click(object sender, EventArgs e) { Response.Redirect ("ChooseTheme.aspx"); } } ChooseTheme.aspx: %@ Page Language="C#" AutoEventWireup="true" CodeFile="ChooseTheme.aspx.cs" Inherits="ChooseTheme" %> Choose your Theme Themes Manager GreenTheme RedTheme BlueTheme ChooseTheme.CS: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class ChooseTheme : System.Web.UI.Page { protected void btnApplyTheme_Click(object sender, EventArgs e); private static string theme; protected void Page_PreInit(object sender, EventArgs e) { if ((theme != null) && (theme.Length != 0)) { Page.Theme = theme; ddlChooseTheme.Text = theme; } else { Page.Theme = "GreenTheme"; } } protected void ddlChooseTheme_SelectedIndexChanged(object sender, EventArgs e) { theme = ddlChooseTheme.SelectedItem.Value; Response.Redirect(Request.FilePath); } } This post has been edited by Jareed: 15 December 2008 - 02:17 AM
VIEWS ON THIS POST

134

Posted on:

Saturday 24th November 2012
View Replies!

Web.Config

hii am working in asp.net with c#.My first question:i have written the connection string in the Configuration Settings in the web.config file.my question is how to make the settings non-editable i.e. no users should able to modify the username/password.My second question:for example say , my project is running on the client place.i have written the connection string in the Configuration Settings in the web.config file.In companies they will change the username and password for the database for every certain time period. Is there any possible chances to change the username and password periodically through coding.if so please explain me with the coding part.please help me
VIEWS ON THIS POST

296

Posted on:

Sunday 25th November 2012
View Replies!

How to integrate Fedex in c# asp.net

I want to get charges details using fedex in c# asp.net. How can I do this Any sample code
VIEWS ON THIS POST

186

Posted on:

Tuesday 27th November 2012
View Replies!

ASP.net SQL Notification Services? Help

NotSupportedException: Notifications require SQL Server 9.0 or later.]Trying to remove this from showing up.Only shows on application startup. (when I visit the site)Any idea how to remove this Its on a hosted provider (shared hosting)... and wondering how I can fix / remove this from appearing. It's kinda annoying.
VIEWS ON THIS POST

168

Posted on:

Tuesday 27th November 2012
View Replies!

ASP.NET 2.0 Crystal ttx file problem

I want my Crystal report to use ttx file.I have this code:Public Declare Function CreateFieldDefFile Lib "p2smon.dll" (ByVal lpUnk As Object, ByVal fileName As String, ByVal bOverWriteExistingFile As Long) As LongAnd in my function:\t\t\t\t\t\t\t\tdt = New DataTable\t\t\t\t\t\t\t\tdt = ....I fill dt\t\t\t\t\t\t\t\tCall CreateFieldDefFile(dt, "C:\Documents and Settings\xxx\My Documents\Visual Studio 2005\WebSites\Test\Crystal\Test.ttx", True)But I got error:"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."Could somebody help me with this
VIEWS ON THIS POST

193

Posted on:

Tuesday 27th November 2012
View Replies!

Processing field in Repeater or dataReader - how?

I have a problem in that I want to format some text in a repeater field. The repeater is being bound to an datareader.My page code is in the form (with only the important bits shown)......\t\t\t\t\t\t\t\tAuthor...\t\t\t\t\t\tand the code behind (in NewsList.aspx.vb) does the bind using the routine:\t\tPrivate Sub BindRepeater()\t\t\t\tDim news As New MiddleTier.NewItemsDB\t\t\t\trpNews.DataSource = news.GetNewsList\t\t\t\trpNews.DataBind()\t\tEnd Subwhere GetNewsList is a function that returns a dataReader read from an sql database.What I want to do is process the txtDescription so that a class function I have written:Namespace SharedCode\tPublic Class textToHTMLConversion\t\t\t\tPublic Function URLEncode(string As String) As Stringwhich converts links in a string to hyperlinks, (ie www.bbc.co.uk to www.bbc.co.uk)does this to the txtDescriptionWhat I really want to be able to do is in the page putto do the conversion. However, I cannot import the sharedCode class into the page (only the code behind page), so it doesn't recognise the shared code.Is there anyway I can do this or an alternate method I can format the description field. Is there a way of looping through cells of the individual rows of the repeater for example
VIEWS ON THIS POST

168

Posted on:

Tuesday 27th November 2012
View Replies!

Pass Value from One Page to Another

I have a webform that contains master records and another webform that contains detail records.\tBoth pages contain datagrids that house their respective data.There is a template column on the master webform containing a hyperlink that, when clicked, opens the detail webform and displays the appropriate detail records.\tI've managed to code this template column to pass the FlitchNum as the querystring into the details webform.[code]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[code]Along with the FlitchNum field, I also need to pass over another column in the datagrid.\tThe purpose is to simply have the data on that column display in the title of the webform.\tIn order to pass another value, should I modify this code to include the additional value, or should I have a separate process\t
VIEWS ON THIS POST

194

Posted on:

Tuesday 27th November 2012
View Replies!

dynamic menu

i want to create a web user control that receives a parameter, and depending on the parameter received i want to create different menu options.how can i do that
VIEWS ON THIS POST

189

Posted on:

Tuesday 27th November 2012
View Replies!

Prevent caching when linking to a generated PDF file

I have an app that lets a user enter some parameters, generates a Crystal Report then exports it to a PDF file and provides the user a hyperlink to that file.\tSometimes after running multiple reports with different parameters, clicking the link will open a cached version of the file in the Acrobat plugin instead of the new one.\tI have verified that the correct file is being generated and the old one is being deleted, but the user still gets the old file.\tClicking refresh on the IE toolbar brings up the correct file.Is there a way to force this link to get the new file instead of a cached version\tI know with an ASP or HTML page, you can do this in a page directive but I can't figure out how to do it with a PDF file.\tIs there anything that can be set in web.config that will prevent caching for the whole app\t the app does is generate reports, and they change based on the parameters entered, so I really don't want anything to be cached.
VIEWS ON THIS POST

174

Posted on:

Wednesday 28th November 2012
View Replies!

Assigning IP address to Website

, I'm not sure if this is an ASP question or an IIS question.I have a web application which is in ASP.NET 2.0 running on a server.\tWhen configuring the website on the "Web Site" tab, does it matter if I leave the IP address on ( Unassigned) or should I specify the IP address\tIf I don't specify, it appears that the service is looking for requests from two different locations (local server's IP address and also the NLB IP address).\tCould this possibly cause a performance problem since it's trying to watch 2 locations
VIEWS ON THIS POST

183

Posted on:

Friday 28th December 2012
View Replies!

Need ODBCCommand to timeout

,I have an ODBC connection to a MySQL database from an ASP.NET page in VB.\tHere is how I setup my Command:CODEDim OdbcCommand As OdbcCommand = New OdbcCommand()OdbcCommand.CommandTimeout = 10OdbcCommand.Connection = MySQLConnectionOdbcCommand.CommandText = CommandTextYou'll notice I have my CommandTimeout set to 10 seconds.\tThis is because the query is for a report being run on a production machine.\tI know that's not ideal, but it's the way it is.\tThe report page will allow for some huge reports to be run that will easily pull the server down for 10 or more minutes.\tI need to limit the ammount of time that will be spent on this query and notify the user that the report was too large to run if it timesout.So... the problem is the above query NEVER times out.\tI ran a report that took 4 minutes and the query never timedout.\tIs there some other way to assure that a query will timeout in a certain time
VIEWS ON THIS POST

141

Posted on:

Tuesday 1st January 2013
View Replies!

FindControl

Can anyone tell be how I would access the properties/methods of a conrol that is inside a table in a formviewCODE\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t }...the bane of my life!http://www.fuzzyd.co.uk
VIEWS ON THIS POST

122

Posted on:

Tuesday 1st January 2013
View Replies!

ASP .NET Project Deployment

Hi Guys,I have a completed .NET project which I now want to package. I have added a deployment project to my solution and I can see how I can add files to the deployment.My quesiton is which files do I need to add as I dont want to add the project files only the ones that are required for the install. Can anyone point me in the right directionm on this
VIEWS ON THIS POST

171

Posted on:

Tuesday 1st January 2013
View Replies!

How to deal with dynamic controls?

I want to have re-usable page elements on my site.\tThese elements will be laid out in HTML, and will use server controls and custom controls.\tA simple example for a page element would be something like this:foo!bar! baz!quux!(where jl is the tag prefix for the namespace that contains my custom controls)It would seem that .ASCX user controls would be perfect for something like this.\tHowever, user controls cannot be used across applications.\t.NET 2.0 gives us the ability to precompile user controls, which are then usable across applications.\tHowever, I need a non-programmer to be able to make changes to these user controls.\tHence, precompiling seems to be out of the question.\tI feel like I can accomplish what I need by saving a given page element to a string in the database.\tWe'll call this string the "input string".\tI can then render the input string through a user control of some sort.\tHowever, there's a snag - how do I render the input string in such a way that the control tags are properly rendered as controlsI've tried to do simple things like this :this.Response.Write(strInputString);However, in place of my custom control, it outputs nothing at all.What are some good strategies for solving this problem\tIs it necessary to have something that parses the input string, builds a controls hierarchy, and then adds that hierarchy to the webform\tIf so, is there anything built into .NET that can help me
VIEWS ON THIS POST

191

Posted on:

Tuesday 1st January 2013
View Replies!

variable into session variable

I have a table of values that have the same name as session variables.\tI'm trying to pass an item from the table into the code below to check the session variable. if session(" & rs1.Field(2).value & ") ="big" thenone of my session variables has the value big, but the if then doesn't fire.\tDoes anyone see anything wrong with my syntaxp.s. I'm a newbie to asp.
VIEWS ON THIS POST

192

Posted on:

Tuesday 1st January 2013
View Replies!

Displaying a set amount of characters in a datagrid cell

I am trying to find a way to populate a datagrid with summary information so that the user can decide whether or not they want to view it. My problem is I have five fields and the fifth is a varchar(500). I do not want to display all 500 characters in the datagrid. Just the first 25. I realize that I can modify my stored procedure to only pull back the first 25, but I am using this stored procedure in other places and would rather not do that. Is there a way to use the Data Formatting Expression within the property builder to handle this If so, what would the syntax be
VIEWS ON THIS POST

241

Posted on:

Tuesday 1st January 2013
View Replies!

Error using OWC

I am trying to use OWC to create charts. I got the following error when I was declaring OWC11.ChartSpaceClassanyone has experience the same problem beforeI reinstall the OWC. still does not fix the proble
VIEWS ON THIS POST

191

Posted on:

Tuesday 1st January 2013
View Replies!

Datagrid keeps changing size(length and width)

I have a datagrid bound to a dataset from a database...The grid grows as the total count increases...that is fine as I don't have that many records.\tYet when it grows it changes the size of the grid.Is there a way where I can keep the column sizes and fonts the same size no matter how many records I have\tFor some reason it changes size
VIEWS ON THIS POST

180

Posted on:

Tuesday 1st January 2013
View Replies!

Anyone know why this page won't upload

I'm uploading an entire asp.net project to my server for the 1st time and I thought I had everything set up properly but I'm getting an error when I try to access the page.Can you please check out this page and perhaps point me in the right direction as to how I can fix this http://209.18.80.111/pages/index.asp
VIEWS ON THIS POST

88

Posted on:

Tuesday 1st January 2013
View Replies!

can't display image using

Hi all,\t\tI am newbie of .NET, I want to display images. The code like this:\t\t\t\t\t\tSub page_load()\t\tDim fileid as String\t\t\t\tfileid="../imgs/myimage.jpg"\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIt works in ASP, but not in ASP.Net. Why
VIEWS ON THIS POST

380

Posted on:

Tuesday 1st January 2013
View Replies!

Dynamically view existing Crystal reports in ASP.Net

I currently have about 200 crystal reports that I want to publish to the web.\tI don't want to have to recreate them.\tI was wondering if anyone has a solution to basically passing the report to the crystal object and having it display on a webpage
VIEWS ON THIS POST

153

Posted on:

Wednesday 2nd January 2013
View Replies!

Wizard control

I am using a wizard control and I have setps for contact information, comments and summary. I would like to pass the comments to the summary page for the users to see the comments they write and I am wondering how can I pass the comments to the summary page. any help is appreciated. , here are some issues I see:your start on ActiveStepIndex 2 not ActiveStepIndex 0.your code behind does not have an event for ActiveStepChanged.you pass the email address and body to the SendMail function, but you don't use the arguments, you reference the controls text directly in the function.\tif that's the case simply do Private Sub SendMail()... End Sub. then from the save event call Me.SendMail().you declare a client CustomValidator function, but you don't reference the function in your code.I would also use CSS and/or skin files for HTML formatting to reduce the clutter. Jason MeckleyProgrammerSpecialty Bakers, Inc.
VIEWS ON THIS POST

107

Posted on:

Wednesday 2nd January 2013
View Replies!

Search Query in VB for Visual Studio

I am trying to build a simple search engine for a listing of availble resources and cannot get the DataList to change the shown results.My current code is as follows:Protected Sub cmd_Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmd_Search.Click Dim SearchString As String Dim SearchField As String SearchString = "'" & txt_Search.Text & "'" If combo_SearchCategory.SelectedValue = "Title" Then SearchField = "[Title]" ElseIf combo_SearchCategory.SelectedValue = "Author" Then SearchField = "[Author]" ElseIf combo_SearchCategory.SelectedValue = "Competency" Then SearchField = "[Competency]" End If SqlDataSource1.SelectCommand = "SELECT * FROM [dbo_Resource] WHERE [dbo_Resource]." & SearchField & " CONTAINS " & SearchString lbl_SQL.Text = SqlDataSource1.SelectCommand End SubAny input would be greatly appreciated,
VIEWS ON THIS POST

53

Posted on:

Wednesday 2nd January 2013
View Replies!

Need Basic Tutorial Site

anyone know of a good site to cover the basics as far as VS goes (with C#) like creating a DB connection, opening a RS...
VIEWS ON THIS POST

107

Posted on:

Wednesday 2nd January 2013
View Replies!

Corect place to declare DB connection ?

,I have a general question about the ADO connection object. In my project, I've create a module that's inthe app_code folder and looks something like this:Public Module Database\t\tPublic MyConn As OleDb.OleDbConnection\t\tPublic Sub OPEN_DB()\t\t\t\tTry\t\t\t\t\t\tMyConn = New OleDb.OleDbConnection(ConfigurationManager.AppSettings("ConnectionString"))\t\t\t\t\t\tIf MyConn.State ConnectionState.Open Then MyConn.Open()\t\t\t\tCatch ex As Exception\t\t\t\t\t\tMyConn.Dispose()\t\t\t\t\t\tHttpContext.Current.Response.Write(ex.Message)\t\t\t\t\t\tHttpContext.Current.Response.End()\t\t\t\tEnd Try\t\tEnd Sub End Module Now in my pages I refer to this module when I need to open a new connection. Example: Public Function GetSomething() As String\t\tTry\t\t\t\tCall OPEN_DB()\t\t\t\tDim SQL As String = "SELECT field FROM MySampleTable WHERE ID = 1"\t\t\t\tDim MyCMD As New OleDb.OleDbCommand(SQL, MyConn)\t\t\t\tRES = CType(MyCMD.ExecuteScalar(), String) \t\t\t\tMyCMD.Dispose()\t\tCatch ex As Exception\t\t\t\tCall READ_EXCEPTION(ex)\t\tFinally\t\t\t\tMyConn.Close\t\t\t\tMyConn.Dispouse\t\tEnd Try\t\tReturn RESEnd FunctionThis works great except now I get occasional errors thrown by the application saying that either the connectionis not open, or is initializing or connection's current state is closed etc. This does not happen all the time and simply refreshing the page with the error will get rid of it, which leads meto believe that perhaps the declaration of the MyConn object in the module isn't such a good thing.When the MyConn is declared the way I have it can I cause any problems
VIEWS ON THIS POST

185

Posted on:

Wednesday 2nd January 2013
View Replies!

Run button click event after enter is pressed

I have a webform containing a textbox control and a button control.\tThe user populates the textbox and then clicks the button, which subsequently runs a click_event.\tHow could I setup the textbox so that the user can simply press the keyboard "Enter" button to fire the button's click_event instead of having to click the button --Mike
VIEWS ON THIS POST

392

Posted on:

Wednesday 2nd January 2013
View Replies!