Vb.net - Request.LogonUserIdentity.Name Returns Server Credential Not The Users Credential
Feb 15, 2011
I am building a simple intranet site and want to get the employees user name, but when i use Request.LogonUserIdentity.Name , i keep getting the servers credentials and not the users. what am i doing wrong and is there a better way to do this.
I am using if (HttpContext.Current.User.Identity.IsAuthenticated){ //do sth. } in my web service to do credential. Is that good enough? or is there some best practices that I can follow?
WebApp1: on IIS and configured with Windows authentication. Get User account from AD.
WebAPP2: a java web app on another windows box in same domain with authentication from AD
On web app1, I have a http handler like
public class MyHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string url = "http://WebApp2/Test"; HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url); CredentialCache myCache = new CredentialCache(); NetworkCredential netCredential = new NetworkCredential("myname", "mypassword", ""); myCache.Add(new Uri(url), "Basic", netCredential); //... myReq.Credentials = myCache; //.... } }
in above way, I can set authentication in code and pass it WebApp2.
But I don't want to put name and password in code. User info already available on WebApp1: in context.User I can find out the user info who already logined into WebApp1, so I want to pass this credential to WebApp2. I have tried to do following:
My web application is on a Webserver that is in a DMZ .
the web application must save on the server in LAN some files, but the webserver cannot access the file server because has no right to access. i wouldn't create an account for the web server, but i would that any time the application has to upload a file onto the file server make a connection that encapsulate credentials, then the upload starts ,finally the connection closes.
Is possible with some Objects to do this type of work?
Previously I had thread Send Mail? That helps me to send mail through Gmail credential account. Now I want to send Email through my server (suppose my server name is [URL]) so what should I do?
I want to centralize authentication that developers are free to worry about the implementation of security. I dont want to validate the authentication at each request like
public class HomeController : BaseController { public ActionResult Home() { if (Request.IsAuthenticated == true) { return RedirectToAction("Home", "Member"); } return View(); } public ActionResult Resources() { if (Request.IsAuthenticated == true) { return RedirectToAction("Resources", "Member"); } return View(); } }
I have developed an asp.net web service and deployed it Win 2003 server on IIS 6. I tried to access it from my asp.net application which is in developer pc, i'm getting a dialog-box "Discovery Credential for Proxy Server"... which asks for a user and password.
Even when I provided right credentials it is not accepting. May be this is because of firewall. How can I get rid of this.
At one point this was working, but somewhere something happened. What I am trying to do is simply download a page from our local site. I keep getting the 401 unauthorized.
I have tried NetworkCredential("user", "password", "domain")
and
CredentialCache cc = new CredentialCache(); cc.Add(new Uri("http://site/"), "Windows", new System.Net.NetworkCredential("user", "password", "domain"));
but that didnt work . We are using Windows authentication with no anonymous access.
How to pass user credential from ASP.Net application to open Report Manager in a new window. When I'm searching in the net, basic authentication was the solution I found. But don't know to pass credential through code
Because of some situation , I had to save users password in session state for short period of time .it unsafe holding some important data in session state?
I want to open B site as new window from A site, so its ask for windows credential. I have credential in A site. I am opening B site using Javascript.window.open.
I created a MembershipProvider WCF service which my website is using as its AspNetSqlMembershipProvider. I'm experiencing delays (eg. 20 seconds) in logging in, but ultimately, I am able to log in. I have a number of "Information" events in the Event Viewer on the machine that houses the MembershipProvider service. This is the error:
Event Type: Information Event Source: ASP.NET 2.0.50727.0 Event Category: Web Event
What are the differences (behind the scenes) between Page.User.Identity and Request.LogonUserIdentity? Not the differences in type, name, etc but the differences in how they're implemented behind the scenes (i.e. one calls windows xxx api and the other calls asp.net xxx api...).
I have IIS on S2k8 and a website with Windows Authentication only.
I can easily reproduce the following scenario, where HttpContext.Current.Request.LogonUserIdentity.Name has a bad value:
Login to website using FireFox, using an Active Directory account "user" (I could use IE to reproduce the same, but it's a few extra steps)Display <%=System.Web.HttpContext.Current.Request.LogonUserIdentity.Name%> on the pageIt shows "DOMAINuser", which is correctI go into Active Directory and rename the account to be "userX" instead of "user" (both SAMAccountName & UPN)Restart FireFoxLogin to website using "userX" accountThe page still shows "DOMAINuser", instead of the expected "DOMAINuserX"
It seems almost as if IIS has cached the old username and it's not showing me the new one, even though I explicitly enter it in the login prompt.
I was/am struggling with security for my first MVC applicaiton. It worked out great for me, but not for my users. I wanted to use Windows Authentication (and I seem to have that working). But when I was still trying to implement it, I was on one of our users computers where they were logged in. I navigated to the main Index page and used the supplied MVC login link and *MY* credentials. So now every time that user navigates to that page, it logs her in as me. We are using IE8, I have deleted all the cookies, passwords, forms information I can fine through Tools|Internet Options|Tool|Content|AutoComplete.
I am runnign the SQL 2005 with Membership structure and two web-applications on the same server box. Each web application uses its own Application Name in aspnet_Applications table. There are two application names. The users from web-app1 could not login to web-app2. Each web-apps uses different Application Pool. Each providers section of Membersip use correct applicationName from aspnet_Applications. The first application is working correct.
The problem is that sometimes the users could not login to web-application 2 during day. I get error Event code: 4006 Event message: Membership credential verification failed. The users start to login again after I Recycle - Stop - Start Application Pool of this web application.
I've got this application that works locally and when deployed and using a .mdf SQL Express database file (which I usually use for testing purposes). However, when I change it to work with our SQL Server 2008 the app works but the service doesn't. For example if in my code behind of a page I have a button that adds data to a table such as this it works fine:
public static string connString = @"Data Source=server1;Initial Catalog=Project;Integrated Security=True"; protected void btnAddProj_Click(object sender, EventArgs e) { using (var sqlc = new SqlConnection(connString)) { sqlc.Open(); var cmd = sqlc.CreateCommand(); int intProjectID; // Add the project info to the database cmd.CommandText = "INSERT INTO tblProject VALUES(@ProjName,@ProjTeam,@ProjStart,@ProjEnd)"; cmd.Parameters.Add("ProjName", System.Data.SqlDbType.NVarChar).Value = txtProjName.Text; cmd.Parameters.Add("ProjTeam", System.Data.SqlDbType.Int).Value = ddlTeamSupported.SelectedValue; cmd.Parameters.Add("ProjStart", System.Data.SqlDbType.NVarChar).Value = txtStartDate.Text; cmd.Parameters.Add("ProjEnd", System.Data.SqlDbType.NVarChar).Value = txtEndDate.Text; cmd.ExecuteNonQuery(); } }
My web.config is setup to use impersonation on that server and all works perfectly well. However, for my service the query doesn't seem to return anything and I get a 400 Bad Request error. The code for the jquery is:
$.ajax({ type: "POST", async: false, url: "Services/ProjectService.svc/test", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { console.log(data); } }); And for the Service: [ServiceContract] public interface IProjectService { [OperationContract] [WebInvoke(ResponseFormat = WebMessageFormat.Json)] ArrayList test(); } public static string connString = @"Data Source=server1;Initial Catalog=Project;Integrated Security=True"; public ArrayList test() { var sqlc = new SqlConnection(connString); sqlc.Open(); var cmd = sqlc.CreateCommand(); cmd.CommandText = "SELECT ProjectID FROM tblProject"; var reader = cmd.ExecuteReader(); ArrayList temparray = new ArrayList(); while (reader.Read()) { temparray.Add(reader[0]); } sqlc.Close(); return temparray; }
If instead of querying the database I have the service just return static data then it works fine. What could cause my service not to be able to connect to the database when the rest of the code behind for the app works?
I have a wcf service that randomly begins to fail when requesting the autogenerated javascript that wcf supports making. But I have no luck tracking down why. The js thing is part of the wcf featureset, so I dont know how it can suddenly begin to fail and be unable to work until IIS is recycled.
The http log gives me:
2010-06-10 09:11:49 W3SVC2095255988 myip GET /path/myservice.svc/js _=1276161113900 80 - ip browser 500 0 0 So its an error 500, and that is about the only thing I can figure out. The event log contains no information.
Requests to /path/myservice.svc works just fine. After recycling IIS it works again, and some days later it begins to fail until I recycle IIS.
I'm experiencing a really confusing error. Exactly every other time the page returns
ERROR [23000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Integrity constraint violation:uniqueness constraint violation (7518)and else it works nicely.
Here's the SQL:
SELECT SlsOrder.Orderdate, SlsLine.LineNum, CASE WHEN SlsLine.AllDelivered = 1 THEN 'X' ELSE '0' END AS 'AllDelivered', Item.ItemName, Item.TechName, SlsLine.IntDlvDate, SlsLine.OrderNum, SlsLine.ItemCode, SlsLine.Version, CEILING(SlsLine.Qty) AS 'Qty', Item.QtyUnit, ROUND((SlsLine.Price*SlsLine.Qty),2) AS 'rowSum', ROUND(SlsLine.Price,2) AS 'Price', IFNULL(SysText.InfoText, '-') AS 'InfoText' FROM PUB.SlsLine INNER JOIN PUB.SlsOrder ON (SlsLine.OrderNum=SlsOrder.OrderNum) INNER JOIN PUB.Item ON (SlsLine.ItemCode=Item.ItemCode) LEFT OUTER JOIN PUB.SysText ON (SlsLine.SlsLineKey=SysText.SysTextKey) AND SysText.NoteType = 'OrdConfRowE' AND SysText.ConsTxt = '' WHERE (SlsLine.OrderNum = '" & o & "') ORDER BY SlsLine.LineNum
I have a dynamic catalogue, where customers select products they are interested in. The manager of the company I am doing this for would like to be able to create an up to date offline catalogue at any given time, to send out to customers who dont have an internet connection. So far its going really well. I am using Server.Execute to get the content for each page, then putting it in static html pages and changing the dynamic links to static html links (ie changing all aspx links to htm). I am able to output all the pages for about us, contact us, home, and the entire catalogue. However, one of the stylesheets which is included in the page based on the URL (if the page is in the administration section then it is not included, otherwise it is) is not being included in the pages when it should be. I have tried outputting the URL but it just returns the URL of the calling page, not the page being called.
Simple mvc page with a few controls that includes a validation summary area.
Once the fields are completed there's a download button.
If I enter something invalid, as expected, my controller code updates the UI with the appropriate error. However, if I then correct the error, and then click the download button a file is downloaded, but the UI never gets updated - presumeably since there's no update on the view.
I am new to webmatix and I do not do much development. I was trying to get some values from a request object and it's probably something very stupid I am doing wrong but really I cannot see what it is. This is the code I am trying to use, but I get no value from any items from the form:
@{ Layout = "_SiteLayout.cshtml"; Page.Title = "test"; if (IsPost)