This project has moved. For the latest updates, please go here.

SPGetCurrentUser() issues...

Mar 23, 2010 at 7:00 PM

Here is the scenario:

browsers :
firefox 3.5.8
I.E. 8

I have a list that isn't inheriting permissions , and it has a group as administrator.

WHenever i create a list item ( only the administrator group has this right),  i assign a person ( a field of type person, who will be the solicitant)  , then, using an event handler in c#, i assign permissions  to that item for colaboration for the solicitant.

So, if I logon with the solicitants user , it won't work any jquery statement, neither the document.ready.. It seems that pops up an exception  of the type 'object expected' or so, and it won't work.

Notice that the solicitant is a new person who has never loged in to this site / web before, and isn't part of any group and hasn't special permissions over nothing in the site collection.

I've put the document.ready into a try and the catch executes but if I put any JQuery statement ( for example , a selector $('textarea:[title="whatever"]'), it will re- throw the same exception and it won't work.

SO, i was unable to accomplish my jquery ideas until i went to  users and groups - > groups  - > configuration - > configure grups

and set into the group of visitors,  the  person 'NT auhotity \authenticated users'.

Once I did that, i was able to  make work my jquery code, it's kind of weird...  Do you know what other solutions that I could have? I don't like this accomplishment.


Then, in IE 8, if i click  on user - change user - , then, the SPGetCurrentUser() will remember only  the first logged user ... so  it seems that something is being cached...

Is there a solution fot this problem?

In firefox , it works fine :):)

Im sorry for being a pain for you, but please help me, i'd appreciate it so much.

Isaac Chacón.

Mar 23, 2010 at 7:19 PM
Edited Mar 24, 2010 at 5:47 PM


I'm not sure I follow everything above, but SPGetCurrentUser is really very simple. It just loads the _layouts/userdisp.aspx page and grabs the user's account.  So if you are logged in, it will grab the account for the user you are using.  That's it.

There must be something else which you are doing which is causing the error, unless I'm missing something.


$.fn.SPServices.SPGetCurrentUser = function() {
  var username = "";
   async: false, // Need this to be synchronous so we're assured of a valid value
   url: $().SPServices.SPGetCurrentSite() + "/_layouts/userdisp.aspx?Force=True", // Force parameter forces redirection to a page that displays the information as stored in the UserInfo table rather than My Site.
   complete: function (xData, Status) {
    $(xData.responseText).find(" td#SPFieldText").each(function() {
     if(/FieldInternalName=\"Name\"/.test($(this).html())) username = $(this).text();
  return username.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
Mar 24, 2010 at 9:42 PM

When you change users, does the Welcome Message at the top of the page display the second user?  What about after you refresh the page again?

I've seen this from time to time, but I've never understood it.  I just posted a question about it over on

Because of the way I'm getting the current user, I don't think we can consider it a bug with my code (I'd admit it if it were), but obviously it's a problem for you. Let's see what we hear over on SPOverflow.  Feel free to add your $.02 on the question.