Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

SPContext.Current.Web.CurrentUser.LoginName in Claim authentication

$
0
0

Hello,

Here is a question for SP2010 server.

I have code on a page to fetch current user loginName info (e.g. dev\testuser1) bySPContext.Current.Web.CurrentUser.LoginName and pass it to SelfServiceCreateSite to create a new site collection.

The code works all OK under  classic Negotiate Kerberos authentication method. However, when I recreate a new web app and use claim-basedintegrated windows authentcation Kerbero, issue as below appears.

SPContext.Current.Web.CurrentUser.LoginName no longer fetches current user info, instead it is "nt authority\\iusr" and SelfServiceCreateSite throws "User cannot be found" error.

Could somebody guide me through how I can still retrieve the current user loginName or so in Claim-based world?

Thanks every much!

MyST

Here is my code snippets ("userName" obtains value of nt authority\\iusr, which is not what I expect)

                    string userName = null;
                    SPClaimProviderManager mgr = SPClaimProviderManager.Local;
                    if (mgr != null && SPClaimProviderManager.IsEncodedClaim(SPContext.Current.Web.CurrentUser.LoginName))
                    {
                        userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
                    }


                    using (
                        SPSite workspaceSite = rootSite.SelfServiceCreateSite(
                            workspaceUrl,
                            title,
                            metadata.WorkspaceDescription,
                            lcid,
                            metadata.WorkspaceTemplate,
                            adminAccount,
                            "",
                            "",
                            userName,
                            "",
                            ""))


from Finland :D



Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>