0

ユーザーの UserId にアクセスする必要があるため、これは user.shared と AuthenticationService を拡張することで実行できると思います。クライアント側で UserId (「Guid」) にアクセスすることが私の目標ですが、デフォルトではこれは不可能です。

@ User.shared 次の行を追加しました。

/// <summary>
/// Gets the UserId of the user.
/// </summary>
public Guid UserId { get; private set; }

ここに AuthenticationService クラス - UserId を返すためにここに何を挿入する必要がありますか??

[EnableClientAccess]
public class AuthenticationService : AuthenticationBase<User> 
{ 
    //adapt GetAuthenticatdUser in order to be able to retrieve the UserId @ the client !
    protected override User GetAuthenticatedUser(System.Security.Principal.IPrincipal principal)
    {

        return base.GetAuthenticatedUser(principal);
        //what does this line above actually do ?!!?

        //INSERT statement which returns the UserId (Guid)
    }
}

皆さん、THX - このトピックですでに少なくとも 1 時間は無駄にしています :-(.

4

2 に答える 2

0

そうですね、文字列を返す FriendlyName を見つけることができました。ただし、これがユーザーIDに関してどのように役立つかよくわかりませんか? ここで私が見つけたもの:

 public partial class User
    {
        /// <summary>
        /// Returns the user display name, which by default is its FriendlyName.
        /// If FriendlyName is not set, the User Name is returned.
        /// </summary>
        public string DisplayName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.FriendlyName))
                {
                    return this.FriendlyName;
                }
                else
                {
                    return this.Name;
                }
            }
        }

        /// <summary>
        /// Gets the UserId of the user.
        /// </summary>
        public Guid UsrId { get; private set; } //I added this line
        //this doesnt really work yet - don't know how to access the actual guid :-(
    }



/// <summary>
    /// Class containing information about the authenticated user.
    /// </summary>
    public partial class User : UserBase
    {
        //// NOTE: Profile properties can be added for use in Silverlight application.
        //// To enable profiles, edit the appropriate section of web.config file.
        ////
        //// public string MyProfileProperty { get; set; }

        /// <summary>
        /// Gets and sets the friendly name of the user.
        /// </summary>
        public string FriendlyName { get; set; }


    }

Web.config には以下のみが含まれます。

<properties>
        <add name="FriendlyName" />
      </properties>
于 2012-06-02T10:57:34.703 に答える
0

Silverlight ビジネス アプリケーション テンプレートを見ると、FriendlyName という UserProfile があります。プロファイルに Guid を詰め込むことができます。

于 2012-05-31T22:49:50.983 に答える