1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / ProfileTypes

ProfileTypes

4 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    29 Apr 2011
    Link to this post
    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.
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    02 May 2011
    Link to this post
    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
  3. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    02 May 2011
    Link to this post
    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,
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    03 May 2011
    Link to this post
    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

    "http://host/YourProject/Sitefinity/Services/Security/Users.svc/?roleId=&roleProvider=&forAllProviders=false&filter=&provider=Default&skip=0&take=20"

    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
4 posts, 0 answered