Advertisement
Guest User

einaros

a guest
Sep 17th, 2009
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. namespace CurrentUserService
  2. {
  3.     using System.Web.Script.Services;
  4.     using System.Web.Services;
  5.     using Microsoft.SharePoint;
  6.  
  7.     [WebService(Namespace = "http://tempuri.org/")]
  8.     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  9.     [ScriptService]
  10.     public class CurrentUserService : WebService
  11.     {
  12.         [WebMethod]
  13.         public string GetCurrentUser(string webUrl)
  14.         {
  15.             using (var site = new SPSite(webUrl))
  16.             {
  17.                 using (SPWeb web = site.OpenWeb())
  18.                 {
  19.                     return web.CurrentUser.LoginName;
  20.                 }
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement