.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

User.Identity.Name returns blank

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
 
Hello, I have a strange problem when trying to get the user name. When I run the asp.net page from local machie it works, but when I run it from the server it doesn't. It's very strange, I have tryied with the following functions: Page.User.Identity.Name System.Web.HttpContext.Current.User.Identity.Name My.User.Name System.Threading.Thread.CurrentPrincipal.Identity.Name User.Identity.Name   All options returns blank :s when I run it in the server Anyone have had the same problem, that could help me please? Thanks in advance.    Also I have the following in web.config <identity impersonate="false"/>    <authentication mode="Windows"/>    <authorization>      <allow users="*" />      <deny users="?" />    </authorization>  and in the IIS enabled  the anonymus authentication and enabled windows authentication  


View Complete Post


More Related Resource Links

User.Identity.Name returns app pool user instead of domain user

  

2 server web farm windows 2008 r2 nlb.  In IIS I enable windows authentication all other authentication is disabled.

 

code behind

       protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Response.Write(User.Identity.Name);
                Response.Write("<br/>");
                Response.Write("Auth user: " + Request.ServerVariables["Auth_User"]);
                Response.Write("<br/>");
                Response.Write("Logon user: " + Request.ServerVariables["LOGON_USER"]);
            }
        }

web.config

    <system.web>
        <authentication mode="Windows" />        
        <authorization>
            <deny users="?" />            
        </authorization>

        <compilation debug="true" targetFramework="4.0" />
    </system.web>



The code returns the application pool custom account e.g. DOMAIN\WebApp_user.  What I want is the logged in user's username.  How do I get this? 


username() function in InfoPath 2010 returns blank when used by FBA authenticated user. works fine f

  

username() function in InfoPath 2010 returns blank when used by FBA authenticated user. works fine for Windows

What gives?? I *REALLY* do need to get this working!

 


Blank Managing My Links Page for Just One User

  

Hello,

I've got a single user who's not able to manage his links in MOSS 2007. The links I speak of are gotting to via http://<<your:mysite>>/_layouts/myquicklinks.aspx. Other users have no issue.

I read somewhere that this might be caused by the user in question having added an improperly formated link. My issue is how can I check for that condition and correct it? Any thoughst would be much appreciated.

 

Thanks,

Jack

 


current user identity in custom security trimmer

  
The crux of my problem is that I want to impersonate  a user’s NTLM credentials in the context of a SharePoint custom security trimmer to execute HttpWebRequests to check user access to URLs.  When accessing WindowsIdentity.GetCurent() in the security trimmer, the System.Security.Principal.WindowsIdentity object returns the identity of the application pool running the search query service, NOT the currently logged in user.   When accessing System.Threading.Thread.CurrentPrinciple.Identity in the security trimmer, the Microsoft.IdentityModel.Claims.ClaimsIdentity object of the current logged in user is returned.  However, there is a catch.  …   If I execute the following code in a .NET web application, the cast of the ClaimsIdentity to a WindowsIdentity succeeds because the identity has the authentication type of NTLM.    WindowsIdentity winId = (WindowsIdentity)System.Threading.Thread.CurrentPrincipal.Identity; WindowsImpersonationContext wic = winId.Impersonate(); request.Credentials = CredentialCache.DefaultCredentials; //access means a response comes back when a request is made to the url using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { returnStatus = true; } wic.Undo(); However, when I execute the same code in the context of the SharePoint security trimmer (the search query service li

Why can't use 'user.identity.name' in masterpage code behind?

  
 I tried to use user.identity.name in a master page code behing  but intellisense doesn't recognize it.   If I change Inherits masterpage to inherit page then intellisense accepts it. What's going On?

user.identity.name="0" when uploading file using ajaxToolkit:AsyncFileUpload

  
hi, i am using AsyncFileupload to upload user picture. after the picture is uploaded and saved i opened another page and i noticed that the user.identity.name is lost. any idea 

httpcontext.current.user.identity.isauthenticated always false

  
Dear, please help me, I create two pages, the first one is the login page with user name and password textboxes - (not asp login control) , when clicking login button I check the login authentication, if it is true redirect to default page. in the default page if !IsCallBack then i check httpcontext.current.user.identity.isauthenticated if it is false i redirect the user to the login page. but my problem is that the httpcontext.current.user.identity.isauthenticated is always false. Below the section of authentication in web config < <authentication mode="Forms">forms loginUrl ="FrmUserLogin.aspx"  protection ="All"  timeout ="1"  name ="LoginRedirectCallback"  path ="/LoginRedirectCallback"  requireSSL ="false"  slidingExpiration ="true"  defaultUrl ="FrmDBLoginConfigaspx.aspx"  cookieless ="UseDeviceProfile"   < < </   </ </enableCrossAppRedirects ="false">credentials passwordFormat="Clear">user name ="admin" password ="admin"/>credentials>forms>authentication> thank you for any help.   Best Regards,

user.identity.name

  
when log in to the system its not taking user name  from  user.identity.name but in a design mode its wroking properly any clue Thanx Niranga  

How to user Appol pool Identity for WCF authorization

  
One of my client has unique requirement.          Details Has Web application, WCF Service both are hosted in IIS6, and runs under a Domain Account (say MyAppAdmin) App_pool. Web application has anonymous access, and service is protected by Windows Authentication. Web App will calls the Service without any impersonation. So Serivice will be called by using App_pool Identity. Below is the code...objClient.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;objClient.ClientCredentials.Windows.AllowNtlm = true;objClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;objClient.Open();svcResult = objClient.MyMethod(input);Problem & requirement: App_pool user is coming to Service, able access using HttpContext.Current.User.Identity, with the properties IsAuthenticated=true; Name=MyAppAdmin. I need check, if this App_Pool user in an Active Directory Group or not. If he is part of allowed group then only I should allow to continue execution of method. For this I am using below codeWindowsIdentity wi = (WindowsIdentity)HttpContext.Current.User.Identity;PrincipalPermission permission = new PrincipalPermission(wi.Name, allowedRoleName, true);permission.Demand();But it is throwing Security.SecurityAccessDe

SharePoint Search returns all where user dont have access

  
Hi, There are around 10 divisional sites and home page in my MOSS 2007 configured with Search feature. The divisional users complained that all the documents are visible to all users, which is not supposed to be. How to restrict the Search based on the user access? Regards Sanra

Master Page User.Identity.Name problem

  

Hello I've written some code to check information based on the authenticated user. The following code works on an ASPX page load but fails when I move into a Master Page. Specifically, the error is "Compiler Error Message: BC30451: Name 'User' is not declared."  

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

' Get & split Domain user Information

Dim strDomainUser As String = User.Identity.Name


page.formsauthentication.user.identity

  

what is the use formsAuthentication.user.identity


is it one of the property of page



GetRoleCollectionFromUser() returns "User Not Found" 0x80131600 in Sharepoint 2007

  

Hi,

I am using GetUserCollectionFromSite() to get the list of users for a site, and with the same list i am calling
GetRoleCollectionFromUser() using login Name i got from previous method. The method is returning a "User Not found" 0x80131600 error. I am the site collection admin for this site and even if i hard code my login name as Domain\UserName(NT ID in this case) i get this error. Please help.

This is in Sharepoint 2007

Thanks,
Vidya


Deveoper

Calling the UserGroup.GetRoleCollectionFromUser returns "User cannot be found"

  
Hello,

We're trying to call the standard SharePoint 2010 web service UserGroup.GetRoleCollectionFromUser. No matter what user we use to authenticate, the web service always returns the same error:
"User cannot be found"
Of course the user does exist and the user name has the form DOMAIN\user. Other methods of the UserGroup web service work fine. In particular, UserGroup.GetGroupCollectionFromUser() with the same user name returns the expected results.

This web service works fine on 2007, although the user privileges required to call it are somewhat unclear.

Thanks,
Raphael Jean

How can I change identity of User Profile Sync Service?

  

1) I cannot remove duplicate managed account with remove-spmanagedaccount because this account is used by user profile synchronization service.

2) I cannot change the account in CA-Configure Service Accounts, it says "item has already been added..." because of duplicate managed account (1)

Is there a way of changing the account of user profile sync service so that it can be removed with remove-spmanagedaccount?

 


current user identity in custom security trimmer

  

The crux of my problem is that I want to impersonate  a user’s NTLM credentials in the context of a SharePoint custom security trimmer to execute HttpWebRequests to check user access to URLs. 

When accessing WindowsIdentity.GetCurent() in the security trimmer, the System.Security.Principal.WindowsIdentity object returns the identity of the application pool running the search query service, NOT the currently logged in user.  

When accessing System.Threading.Thread.CurrentPrinciple.Identity in the security trimmer, the Microsoft.IdentityModel.Claims.ClaimsIdentity object of the current logged in user is returned.  However, there is a catch.

 …

 

If I execute the following code in a .NET web application, the cast of the ClaimsIdentity to a WindowsIdentity succeeds because the identity has the authentication type of NTLM. 

 

WindowsIdentity winId = (WindowsIdentity)System.Threading.Thread.CurrentPrincipal.Identity;
WindowsImpersonationContext wic = winId.Impersonate();
request.Credentials = CredentialCache.DefaultCredentials;

//access means a response comes back when a request is made to the url

SQL Server user-defined aggregate returns an error if aggregating 0 rows

  
I have this SQL Server user-defined aggregate:

[SqlUserDefinedAggregate(Format.UserDefined, Name="median", IsInvariantToDuplicates=false, IsInvariantToNulls=true, IsInvariantToOrder=true, IsNullIfEmpty=true, MaxByteSize=8000)] 
public class MedianCalculator : IBinarySerialize { 
    private List<double> values; 
 
    public void Init() { 
        values = new List<double>(); 
    } 
 
    public void Accumulate(SqlDouble value) { 
        if (!value.IsNull) 
            values.Add(value.Value); 
    } 
 
    public void Merge(MedianCalculator other) { 
        values.AddRange(other.values); 
    } 
 
    public SqlDouble Terminate() { 
        if (values == null || values.Count == 0) 
            return SqlDouble.Null; 
        values.Sort(); 
        return (values[(int)Math.Floor((values.Count - 1) / 2.0)] + values[(int)Math.Ceiling((values.Count - 1) / 2.0)]) / 2.0; 
    } 
 
    public void Read(BinaryReader r) { 
        int c = r.ReadInt32(); 
        values = new List<double>(c); 
        for (int i = 0; i < c; i++) 
            values.Add(r.ReadDouble()); 
    } 
 
    public void Write(BinaryWriter w) { 
        w.Write(values.Count); 
        for (int i = 0; i < values.Count; i++) 
             w.Write(values[i]); 
    } 
} 
After deploying this aggregate, I try to run this query:
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend