2010-06-14 20 views
1

我在Windows身份驗證下有一個SharePoint站點和一個自定義aspx門戶。 使用同一臺機器時,碰巧我的SharePoint站點將我當前的登錄名返回給我,而我的自定義aspx將我的域管理員帳戶返回給我。Sharepoint UserProfileService

有無論如何,我可以確保登錄都是一樣的嗎?否則,是否有消費自定義aspx門戶SPUserProfileService?

主要是,我需要有自定義aspx門戶來獲取共享點登錄ID。不過,我仍然可以在sharepoint中觸發AccessDenied.aspx來提示登錄。

回答

0

當您說「自定義ASPX門戶」時,它是否仍在SharePoint網站上?

在這種情況下,您如何獲得用戶?您可以使用SPContext.Current.Web.CurrentUser來獲取用戶。

0

您似乎在使用您的域管理員帳戶從您的自定義aspx連接到SharePoint。 您能否詳細介紹一下您的自定義aspx門戶以及您閱讀用戶名的方式?

但是,你可以檢查我的文章(即使它是FBA用戶,你可能會發現代碼片段很有用): Possible ways to get logged in User Name & Handling Changes in FBA Users' Names if Membership Provider Name Changed

public string GetFlatUserName() 
{ 
    //First, be sure that the user is not anonymous user: 
    if (SPContext.Current == null || SPContext.Current.Web.CurrentUser == null) 
     return "Anonymous"; 
    //Second, parse it: 
    else 
    { 
     string flatUserName = this.Page.User.Identity.Name; 
     if (flatUserName.Contains("\\")) 
     { 
      flatUserName = flatUserName.Substring(flatUserName.IndexOf("\\") + 1); 
     } 
     else if (flatUserName.Contains("|")) 
     { 
      flatUserName = flatUserName.Substring(flatUserName.IndexOf("|") + 1); 
     } 
     return flatUserName; 
    } 
}