ProfileTypes

Posted by Community Admin on 03-Aug-2018 21:07

ProfileTypes

All Replies

Posted by Community Admin on 29-Apr-2011 00:00

Hello. I'm playing around with the new profileTypes that can be created for users and was just wondering if there is a way to export a type that you've created to use in subsequent websites. So, for instance, instead of having to create an initials field for users each time I create a new website I can just import the custom profileType I've already created.

Posted by Community Admin on 02-May-2011 00:00

Hello KMac,

You can export the custom fields or all fields for a profile you have created by first getting all of the fields in a given profile.

var manager = UserManager.GetManager();
User user = manager.GetUser("admin");
var profileManager = UserProfileManager.GetManager();
var profile = profileManager.GetUserProfile(user.Id, typeof(SitefinityProfile).FullName) as SitefinityProfile;
var properties = TypeDescriptor.GetProperties(profile);
the line

var properties = TypeDescriptor.GetProperties(profile);
gets all of the current properties( default + custom fields ) of the given profile. You will notice the properties have [Data], [Bool], [List] etc before their name. The properties with [Meta] are the custom properties you want to export.
Telerik.Sitefinity.Metadata.Model.MetaFieldAttributeAttribute

To use the custom profiles created in one project to other project you will need to make service that will get them form the source project to your desired one.

Hope this information is helpful to you.

All the best,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-May-2011 00:00

Thanks Stanislav,

Any guidance on how to export back in. I'm not as familiar as I'd like to be with the new Sitefinity webservices. Any code samples to give us an idea of where to begin?

Thanks,

Posted by Community Admin on 03-May-2011 00:00

Hi KMac,

There is Users WCF services that you can use to get the data from one of the websites. Of you can create your own service to communicate between the websites.

You can view Users' service help by typing "http://host/YourProject/Sitefinity/Services/Security/Users.svc/help".  This will show you all available methods that you can use out of the box.

For instance, to get the first 20 users from the default provider you can call

"host/.../

First to get access to the services, you should authenticate a user. It is better to use an admin user, so you can operate with the data properly. Also if you are going to make requests on the same domain you can easily share the authentication cookie, otherwise you need to create a shared repository that you use to get and set the cookie to the response.

You must perform a GET request to the project A - from where you pull users' information from  and send it to project B where you will import the custom properties. Using our service you will receive XML or JSON.

Basically to get the data through the service is easily than saving it. This is why you can use our service only to get the information you need like we do in the migration tool(Sitefinity migration tool that upgrades 3.7 project to 4.0 projects by invoking a service). If you are going to use our service to update a user or create a new one you need to make a web request and using client side System.Net.WebRequest() method.


Kind regards,
Stanislav Velikov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed