Profile

Jul 5, 2009 at 3:20 AM

Hello,

Is it possible to have objects (classes) in the profile as with in SQL Provider?

And how can I get the profile of a given user?

Thanks,

Miguel

Coordinator
Jul 6, 2009 at 6:48 PM

Hi Miguel,

It is possible to have profile items which are object.
Here bellow is a sample of how I use the XmlProviders with custom objects in the profile:

<profile enabled="true" defaultProvider="XmlProfileProvider">
    <providers>
        <clear/>
        <add applicationName="MySampleApp" name="XmlProfileProvider" type="Artem.Web.Security.XmlProfileProvider"/>
    </providers>
    <properties>
        <group name="MyContext">
            <add name="Files" type="Artem.Sample.Data.ProfileBag" serializeAs="Binary"/>
            <add name="Templates" type="Artem.Sample.Data.ProfileBag" serializeAs="Binary"/>
        </group>
        <add name="MyUserSettings" type="Artem.Sample.Data.UserProfile" serializeAs="Binary"/>
    </properties>
</profile>

As you can see in the example above, I even group some of my profile settings.

If I got your second question right, you know you can get the the current user profile in throught the current HttpContext.
If you don't get the profile as strongly-typed object, you can get the items as following example:

ProfileBag bag = HttpContext.Current.Profile["MyContext.Files"] as ProfileBag;

UserProfile up = HttpContext.Current.Profile["MyUserSettings"] as UserProfile;

 

Regards,
Velio

Jul 6, 2009 at 10:54 PM

My second question was more "how to get the profile of the user that is not the not that is signed on". Any idea?