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:
Quelltext
1:
| Parameter 'principal' of domain operation entry 'GetAuthenticatedUser' must be one of the predefined serializable types. |
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> { [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 { [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!