Autor Beitrag
FrEEzE2046
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109

Windows 98, 2000, XP Pro, Vista Ultimate 32 & 64 Bit, Windows 7 Beta 64 Bit
C/C++, C# (VS 2008 TeamSystem) - Delphi (Delphi 5) - Java (Eclipse)
BeitragVerfasst: Sa 27.11.10 19:57 
Guten Abend und vorab schon mal einen fröhlichen 1. Advent.

Ich habe mal wieder ein Problem mit einer Silverlight 4.0 Application beim Zugriff auf einen serverseitigen DomainService. Wie im Code-Listing unten zu sehen, möchte ich Benutzernamen, vollständigen Namen und Benutzergruppen des Client-Benutzers auslesen. "Leider" benötige ich für die Methode GetAuthenticationUser() der Basisklasse (AuthenticationBase<>) einen Parameter des Interface-Typs IPrincipal.

Dabei tuen sich mir gleich zwei Fragen auf. Trotz recherche ist es mir nicht gelungen ausfindig zu machen, was genau ich hier übergeben muss. Desweiteren ist es mir misslungen die Query-Methode kompilierfähig zu bekommen. Offensichtlich scheinen Query-Parameter lediglich auf einfache Datentypen begrenzt zu sein:

ausblenden Quelltext
1:
Parameter 'principal' of domain operation entry 'GetAuthenticatedUser' must be one of the predefined serializable types.					


ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
[EnableClientAccess]
public class AuthenticationDomainService : AuthenticationBase<User>

    // To enable Forms/Windows Authentication for the Web Application, 
    // edit the appropriate section of web.config file.

    [Query(IsComposable = false)]
    public User GetAuthenticatedUser(IPrincipal principal)
    {
        User user = base.GetAuthenticatedUser(principal);
        string[] tmp = user.Name.Split('\\');

        DirectoryEntry entry = new DirectoryEntry("WinNT://" + tmp[0] + "/" + tmp[1]);
        user.FullName = entry.Properties["FullName"].Value.ToString();
        user.Groups = entry.Properties["Groups"].Value as string[];

        return user;
    }
}

public class User : UserBase
{
    // NOTE: Profile properties can be added here 
    // To enable profiles, edit the appropriate section of web.config file.

    // public string MyProfileProperty { get; set; }

    [ProfileUsage(IsExcluded = true)]
    [Editable(false)]
    public string FullName { get; set; }

    [ProfileUsage(IsExcluded = true)]
    [Editable(false)]
    public string[] Groups { get; set; }
}


Welchen Workaround kann ich nutzen um mein Ziel dennoch zu erreichen? Vielen Dank schon mal vorab!