GiuseppePWolf

Hi every1,

I got a new question creating a sample custom application under MOSS:

The scenario is a custom application undere _Layouts\myfolder, the sharepoint portal is on the port 80 and got in the user panel the same users of the local system (no AD active in there)

When in the code i check the SPSite.CurrentUser i see Sharepoint\System..what kind of user is why I dont see the right user i'm logged on (Foo\administrator) I'm checking it from the global when the autenthication begin.

Again...why when I check the group collection of any user using the webservice i got the result of user not exist i send to the webservice the httpcontext user (since i cant retrieve the SPSite current user but i checked using the webservice the user collection and the format seems the same Foo\administrator) and i got an exception of user that not exist...why

Thanks guys



Re: SharePoint - Development and Programming Users, groups and webservices

GiuseppePWolf

just to give some more information what i'm trying to do is:

to retrieve the current user:

SPWeb site = SPControl.GetContextWeb(System.Web.HttpContext.Current);
return site.CurrentUser.LoginName;

and i get Sharepoint\System and not what i want foo\administrator

---------------------------------------------------------------------

to check role of the user (i tryed to force both users in the procedure Sharepoint\System and Foo\Administrator)

FooUserGroup.UserGroup usrgrpService = new FooUserGroup.UserGroup();

XmlNode ndRoles = usrgrpService.GetRoleCollectionFromUser(loginName);

where ofcourse FooUserGroup is the vs link to the webservice

and I always get as response the user doenst exist as exception!

any Idea





Re: SharePoint - Development and Programming Users, groups and webservices

GiuseppePWolf

My guess: since the application is deployed under _Layouts folder it runs with this strange user could be but why i cant retrieve the user role




Re: SharePoint - Development and Programming Users, groups and webservices

Peter ebSms

Let's say your computers name is MYPC. Delete the leading 'MYPC\\' from loginName.

String loginName = HttpContext.Current.User.Identity.Name;

loginName = username.Substring(username.IndexOf('\\')+1);

--- just for fun ---

investigate the following in your code and compare this with the identity of your application pool
...
using System.Security.Principal;
using System.Threading;
...
IPrincipal httpContextUser = HttpContext.Current.User;
IPrincipal threadContextUser = Thread.CurrentPrincipal;
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
...





Re: SharePoint - Development and Programming Users, groups and webservices

GiuseppePWolf

Hi Peter,

thanks for your post but actually if i check the principal and the identity i got always MyPc\administrator

if i try to use just "administrator" in the webservice nothing changes...always the same problem! the user doesnt exist (but itsnt true as you can see from the identity and from the sharepoint user panel)

any other idea Sad





Re: SharePoint - Development and Programming Users, groups and webservices

Peter ebSms

just a test: go to your IIS-Manager and change for your Web Site Directory Security -> Authentication and Access Control -> uncheck 'Integrated Windows authentication' and check 'Basic authentication'

do a iisreset and and let's see if you still get the administrator when authenticating to your web with another user.

Peter





Re: SharePoint - Development and Programming Users, groups and webservices

GiuseppePWolf

no way, same story, popup that ask me the user and whatever i entry the logon goes ok but the webservice call raise the usual error Crying




Re: SharePoint - Development and Programming Users, groups and webservices

GiuseppePWolf

ok..i got some news:

1) i still dont know why the user i get as current is sharepoint\system and not foo\admin

2) if i use any webservice but GetRoleCollectionFromUser i got the right result (using the webservice collection on the 80 port)

3) if I use the webservice on the port 5555 (the admin portal) i can retrieve without problems the GetRoleCollectionFromUser!!!!

there's some reason