ProfileTypes
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.
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);
var
properties = TypeDescriptor.GetProperties(profile);
Telerik.Sitefinity.Metadata.Model.MetaFieldAttributeAttribute
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,
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