static void Main(string[] args)
{
using (SPSite mySite = new SPSite("sitename"))
{
using (SPWeb myWeb = mySite.OpenWeb())
{
string userEmail = "[email protected]";
string userName = Membership.GetUserNameByEmail(userEmail);
Console.WriteLine("Your UserName is: " + userName);
}
}
}
此代碼將重新調用NULL。我在這段代碼中做錯了什麼?如何通過電子郵件獲得用戶ID?
取決於您是否使用SharePoint身份驗證或Windows身份驗證! – 2011-06-14 14:30:54
其在Sharepoint中的表單身份驗證 – NaveedAnjum 2011-06-14 14:50:17
這不是問題的原因,但不要忘記處理'SPSite'和'SPWeb'對象。 http://blogs.msdn.com/b/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx – 2011-06-14 18:47:05