2012-05-31 4 views
0

Мне нужно получить доступ к UserId моих пользователей, поэтому я предполагаю, что это можно сделать, расширив user.shared и AuthenticationService. Моя цель - доступ к UserId (который является «Guid») на стороне клиента, по умолчанию это невозможно.Silverlight - расширение User (или AuthenticationService)

@ 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 час уже на эту тему :-(

ответ

0

Если вы посмотрите на шаблон Silverlight Business Application, есть UserProfile называется FriendlyName Вы можете наполнить Guid в профиле.

+0

Дорогой Чуйской Тей, спасибо за Ваш ответ! К сожалению, я не знаю, КАК это сделать. Я студент C#, наш лектор недоступен, и никто не может мне помочь :-( – SWEapprentice

+0

Вы нашли запись FriendlyName в исходном коде? Если вы ученик-программист, то вы должны изучить хотя бы один инструмент, который будет искать файлы для некоторого текста. –

0

Ну ... да, я мог найти FriendlyName, которое возвращает строку. Однако я не совсем понимаю, как это помогает мне в отношении идентификатора пользователя? :

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> 
Смежные вопросы