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


Post New Web Links

SPContext.Current.Web.CurrentUser returns inconsistent username (With different characters)

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :SharePoint
 

Hello,

We are using MOSS 2007 with browser enabled Infopath forms. We have a user with username "DOMAINNAME\fakgul" (Active Directory also displays the user as this). However when the user opens an Infopath form  the code line behind the form below:

SPUser openedByUser = SPContext.Current.Web.CurrentUser;

returns "DOMAINNAME\fakgül" (with "U-umlaut"). When we enter the "User information" page of that user, "Account" field also displays as "DOMAINNAME\fakgül" (with "U-umlaut").

What is more strange is this is not the consist


View Complete Post


More Related Resource Links

SPContext.Current.Web.CurrentUser.Name returns complete value claims

  

Hi All, 

I just had another interesting issues in claims !

I was using this property SPContext.Current.Web.CurrentUser.Name in my webpart to show user name. 

Before it was working fine but all of a sudden it is showing complete string like this: 

0#.f|providername|name

before it was just showing 'name' only.

So, now i have this ugly formatted username in my welcome control !!

anyone faced the same issue? 

 

Thanks, 

Sanjay



Sanjay

Get current logon user id with SPContext.Current.Web.CurrentUser.LoginName

  
Hi all,I've been trying to search for the method to display the currently logon user id. So far, most sites I've visited used SPContext.Current.Web.CurrentUser.LoginName.I've tried this in my SharePoint custom application page. Everything works great.I have a test account, when logged in, was displayed as xxx\testacc.For some reasons, I changed the id in AD to xxx\test and did a full import to MOSS.I logged in to the custom application with the changed id, i.e. xxx\test, BUT the value of SPContext.Current.Web.CurrentUser.LoginName still displayed as xxx\testacc!How do I get the latest id? Has anyone encountered this before?Thank you.Kelvin

Problem with Spcontext.current.web.currentuser.name

  
Hi all, I am using Spcontext in code to retrive the current user login name. But some times Spcontext.current.web.currentuser.name will return name of the user who is currently logged in it is retruning user name other than the current. When I refresh the page two or three times It will return the proper user name. Can anyone help me to resolve this issue.

SPContext.Current.Web.CurrentUser is null

  
Hi!

I am using FBA in an internet zone of sharepoint site.

I am getting null in Current.Web.CurrentUser object even when i am logged in as FBA User. The welcome message is shown on top to ensure that FBA is working, but CurrentUser is giving null.

The same code works perfectly when logged in as Domain user in Intranet Zone.

Shabih

SPContext.Current.Web.CurrentUser null in application page on 2008 r2 server

  
With my current situation I have:
a wss3 development environment on a 2003 R2 server
then a production 2008 r2 server.

For some reason on the 2008 server the SPContext.Current.Web.CurrentUser object is null for users who are site collection administrators but may not have permission to log into the server itself; however, on the 2003 R2 server the code works fine for those users.
When googling around, I had seen something about nt permissions on the bin folder sometimes being and issue until asp.net cache picks up the dll but this is a page in the _layouts directory and the code is in the .aspx page itself. It works fine for me as a system administrator on either machine.

Any suggestions? Thanks.

SPContext.Current returns a null

  

ok, I am new to the wonder world of WSS and Sharepoint.   The objective of my code is to upload a file into a particular folder into a document library.   Well, I was able accomplish this task ( ONCE ) on a Virtual machine but something happened somewhere and the code below no longer works:

 

public string UploadFile(string folderName, string fileName, byte[] contents)

{            String retVal = "File : " + fileName + " Upload Successfull.";

            try

properties of SPContext.Current returns null after migration

  

Hi,

I use stsadm export to migrate my site from one machine to another. After migration, I found one of my webpart does not work. It throws a null reference exception.

I logged my webpart and found it cannot get SPContext.Current.Web and SPContext.Current.List, the both returns null and cause the exception. I removed the webpart and added it again but the exception still occured. However, I created a new List on the new site then put my webpart in and it works fine.

I think it is because my migration operattion, is there anything need attention during migration?  Why SPContext.Current cannot get properties?


Get current username

  

Hi, I have the following code which I want to get the current username of the user logged in and use it as the @username parameter:

aspx file:

<asp:SqlDataSource ID="SqlDataRegionalUserAreas" runat="server" ConnectionString="<%$ ConnectionStrings:DevCPSdocshare %>"
        SelectCommand="SELECT d.doc_area_name
                        FROM document_area d,document_area_user_access a
                        WHERE a.doc_area = d.doc_area_id
                        AND and a.username=@username">
        <SelectParameters>
        <asp:Parameter Name="username" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

 

aspx.cs file:

string username = Request.QueryString["username"];
        Membership.GetUser();
        SqlDataRegionalUserAreas.SelectParameters[<

Unable to get current username via data connection

  
I'm trying to use a browser enabled form.  I've followed the directions on this site to get the current profile username. http://baigadil.blogspot.com/2008/07/get-current-user-for-infopath-and-set.html When i open the form, i get the following error message: An error occurred accessing a data source. An entry has been added to the Windows event log of the server. Log ID:6932    

Unable to get current username via data connection

  
I'm trying to use a browser enabled form.  I've followed the directions on this site to get the current profile username. http://baigadil.blogspot.com/2008/07/get-current-user-for-infopath-and-set.html When i open the form, i get the following error message: An error occurred accessing a data source. An entry has been added to the Windows event log of the server. Log ID:6932    

SPContext.Current is null in a WebService in the 12 hive layouts

  

Hello,

  I do not understand why I cannot get the SPContext.Current instance.  It must be an IIS Setting because I get it on one machine and not on another, using identical code.


userName() function returns the original form author on alternate view

  
I am working with an InfoPath 2010 form using web forms (SharePoint InfoPath Forms Services).  The form has two views.  The first view for submitting a "Project" and another view for users to comment on that project.  There is one field (ProjectAuthor) which records the original author using the userName() function.  On the second view, I have another field (CommentAuthor) also set to use the userName() function to record the person making the comment.  When that second view is opened by a different user, the original author of the form is populated in that field and not the commenter.  I have tried both checking and unchecking "Refresh value when formula is recalculated" but that does not change the value.

SPContext.Current is null In Custom Membership ValidateUser

  

Hi,I just get a problem getting SPContext.Current in Custom membership Provider.

We have successfully plugin the custom membership into Sharepoint foundation 2010. We tried to programmically update the user's full name after user logs in and it failed in 2010 version. (good in 2007)

This is the simplified code. The class is a custom membership provider.Strangely, this only happens in 2010 version and never raised a problem in 2007.

public override bool ValidateUser(string username, string password)
  {
  
   bool isvalid = false;
   try
   {

    if(username=="admin" && password="pwd")
      isvalid = true;
 
     var webContext = SPContext.Current.Web; //this returns null

    }
   }
   catch (System.Web.Services.Protocols.SoapException exp)
   {
    System.Diagnostics.Debug.WriteLine(exp.InnerException);
    Logger.WriteLog(exp.InnerException.ToString(), "wss login error");
    
    
   }
   return isvalid;

  }

Please Help. Thank you.

Rui

 


SPContext.Current.Web is not latest

  

I am creating a list with a deployed list template. with the following code:

SPSite site = new SPSite("http://servername");
SPWeb web = site.OpenWeb();

web
.Lists.Add(listName, listName, listTemplate);
SPList List = Web.Lists[listName]

Why is FieldValue and SPContext.Current.Item["DateColumn"] different?

  

I have a custom application page which i am using to format the SPListItem in a particular layout. On this page I am showing a datetime field as:

 <SharePoint:FieldValue runat="server" FieldName="IssueDate" id="FieldValue13"/>

But its showing me -1 day of the original value of IssueDate. So 10/5/2010 shows as 10/4/2010. I have solved this by formatting the value manually :

 <%= SPContext.Current.Item["IssueDate"].ToString() %>   

my question is why would FieldValue show -1 of the original value?


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!

 


WebRequestMethods.Ftp.GetFileSize returns inconsistent results

  

The FTP server of interest is probably Unix type and the uploaded files have different sizes than their local counterparts residing on a computer running Windows.

The following is what I observed.

1. After uploading a file using WebRequestMethods.Ftp.UploadFile, the file size retrieved immediately by using WebRequestMethods.Ftp.GetFileSize is exactly the same as the local file size  which is not correct.

2. After a bunch of FTP operations, the file size retrieved by the same method (i.e. using WebRequestMethods.Ftp.GetFileSize) is the correct size which is different from the local one.

This may be an FTP server issue.  I am asking just in case it is related to how FtpWebRequest works. 

Could  anyone shed some light on this?

 


hz
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