More in this section

Forums / General Discussions / integrating Sitefinity 4 with SalesLogix

integrating Sitefinity 4 with SalesLogix

15 posts, 0 answered
  1. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    22 Dec 2010
    Link to this post
    Hello,

    I am evaluating Sitefinity 4 and will need to connect to a SalesLogix backend which contains all of our user information.  Is there a way to customize the Sitefinity Login/Register functionality to access the SalesLogix database so you would not have to have two sets of user info (one in the Sitefinity database and one in the SalesLogix database) ?

    thanks
    Dan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Dec 2010
    Link to this post
    Hi Dan,

    You need to implement a custom membership provider that inherits from MembershipDataProvider class and represent your SalesLigix users as Sitefinity's Security.Model.User object. Then you have to associate these users with roles in Sitefinity.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    06 Jan 2011
    Link to this post
    Hello Ivan,

    I have implemented the code you provided and added and enabled the new customer provider as demonstrated in this screen shot from another thread:

    http://www.sitefinity.com/ClientsFiles/231376_membershipsetup.png

    However, when I go to the users page as shown in the video you provided in the other thread, I am not given the option of choosing my new provider. In your video, you see "All Providers Default MembershipProviderCustom" above "Create User".  I do not see that.

    Am I missing a step somewhere?

    Thanks!
    Dan
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Jan 2011
    Link to this post
    Hello Dan,

    Could you try to restart the application by making a dummy change in the web.config and see whether the provider will appear. Also make sure that you are using the correct type to register the provider.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    06 Jan 2011
    Link to this post
    Hi Ivan,

    The code you provided is working now (doing a dummy update to web.config worked).

    The next question I have is am I going to have to actually create a user in Sitefinity based on the SalesLogix user.  By doing so I would be having to store two sets of user information. For example:

    var manager = UserManager.GetManager();
    var q = manager.GetUsers().Where(us => us.UserName == "somesalesLogixUser").SingleOrDefault();
                if (q == null)
                {
                    var u = manager.CreateUser("somesalesLogixUser");
                    manager.SaveChanges();
                    list.Add(u);
                    return list.AsQueryable<User>();
                }

    Or could I do something similar to the following:

     m_SLXDataAdapter.SelectCommand = new SqlCommand("select * from contact where email = 'dmartin@jpg.com'  and importsource is NULL", m_SLXConnectionString);
                nFillErr = m_SLXDataAdapter.Fill(m_SLXDataSet);

                m_SLXDataTable = m_SLXDataSet.Tables[0];
                User myUser = new User();
                if (m_SLXDataTable.Rows.Count > 0)
                {
                    DataRow SLXDataRow = m_SLXDataTable.Rows[0];

                    myUser.Email = SLXDataRow["EMAIL"].ToString();
                    myUser.FirstName = SLXDataRow["FIRSTNAME"].ToString();
                    myUser.LastName = SLXDataRow["LASTNAME"].ToString();
                    myUser.LastLoginDate = new DateTime();
                    myUser.Id = new Guid("965e389c-c3f9-4fed-8ff3-87a98b3e7ac7");
                    myUser.UserName = SLXDataRow["EMAIL"].ToString();
               }
                List<User> list = new List<User>(1);
                list.Add(myUser);

    thanks
    Dan
              






    I am able to get "user" information from our SalesLogix database, but I am having issues creating a User object. 


    thanks
    Dan

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jan 2011
    Link to this post
    Hi Dan,

    There is no problem to use SQL queries to your database to get or create the users. Actually you only need to get the object from your database and return it as a Security.Model.User.

    Note that GetUsers() loads all users into the memory and if you have many users you should consider a way to filter them.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    07 Jan 2011
    Link to this post
    Hi Ivan,

    I am having trouble converting the user information from our SalesLogix database into a Security.Model.User object.

    I tried the create a Security.Model.User object using the following code but I am not able to set certain fields such as username.  Is there another way I need to go about creating a Security.Model.User object?

    m_SLXDataTable = m_SLXDataSet.Tables[0];
                User myUser = new User();
                if (m_SLXDataTable.Rows.Count > 0)
                {
                    DataRow SLXDataRow = m_SLXDataTable.Rows[0];

                    myUser.Email = SLXDataRow["EMAIL"].ToString();
                    myUser.FirstName = SLXDataRow["FIRSTNAME"].ToString();
                    myUser.LastName = SLXDataRow["LASTNAME"].ToString();
                    myUser.LastLoginDate = new DateTime();
                    myUser.Id = new Guid("965e389c-c3f9-4fed-8ff3-87a98b3e7ac7");
           
                }

    thanks
    Dan
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jan 2011
    Link to this post
    Hello Dan,

    The user should have a username. If you do not have such a column in your database try using the FirstName.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    10 Jan 2011
    Link to this post
    hi Ivan,

    My issue was that I was unable to set the username property directly as it is read only....I did not notice the setusername method.

    Now I am getting a "Null object error"....I believe because the user Provider property is not set.  It is read only and I do not see a set method for it.  How should I go about setting the user Provider property?

    thanks
    Dan
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Jan 2011
    Link to this post
    Hello Dan,

    Could you show the stack trace of the error and the code you are using? Where actually it fails?

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    11 Jan 2011
    Link to this post
    hi Ivan,

    Below is the code I am using (the exception is thrown after the function returns).  When running the sample website, I select "Go To Sitefinity Adminstration" and then select my custom provider when logging in.  The exception is thrown during the login process.  Also when I look at the myUser object in debug mode I see the following exception assigned to the Provider property:

    Provider='((Telerik.Sitefinity.Security.Model.User)((new System.Collections.Generic.Mscorlib_CollectionDebugView<Telerik.Sitefinity.Security.Model.User>(list)).Items[0])).ProviderName' threw an exce...

    Alternatively, if I login with the Default provider and then go to user management and select my custom provider, a "null object message" is displayed on the screen.


     code below

      public override IQueryable<Telerik.Sitefinity.Security.Model.User> GetUsers()
            {                      
                    User myUser = new User();

                    myUser.Email = "test@jpg.com";
                    myUser.FirstName = "John";
                    myUser.LastName = "Smith";
                    myUser.LastLoginDate = new DateTime();
                    myUser.Id = new Guid("965e389c-c3f9-4fed-8ff3-87a98b3e7ac7");
                    myUser.SetUserName("test123");
                    myUser.SetCreationDate(new DateTime());
                    myUser.ApplicationName = "Backend/";
                    List<User> list = new List<User>(1);
                   
                    list.Add(myUser);
                    return list.AsQueryable<User>();
              }

    ------------------------------------------------------------
    Below is the stack trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       DynamicModule.ns.Wrapped_MembershipDataProviderCustom_4cc842b20c284db5bca3de91eace067c.Clone() +225
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +674
       Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName) +249
       Telerik.Sitefinity.Security.UserManager..ctor(String providerName, String transactionName) +39
    
    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType) +0
       System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType) +15
       System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +281
       System.Reflection.ConstructorInfo.Invoke(Object[] parameters) +17
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +1323
       Telerik.Sitefinity.Security.UserManager.GetManager(String providerName, String transactionName) +41
       Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser(String membershipProviderName, String userName, String password, Boolean persistent, User& user) +70
       Telerik.Sitefinity.Security.Web.UI.LoginForm.LoginForm_Authenticate(Object sender, AuthenticateEventArgs e) +189
       System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +115
       System.Web.UI.WebControls.Login.AttemptLogin() +127
       System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    --------------------------------------------
    
    Lastly, As a test, I changed to the code below and still get the exception thrown when trying to login 
    with the customer provider:
    
      public override IQueryable<Telerik.Sitefinity.Security.Model.User> GetUsers()
            {
      var manager = UserManager.GetManager();
     
    List<User> list = new List<User>(1);
     
    list.AddRange(manager.GetUsers()); return list.AsQueryable<User>();
            }

    thanks
    Dan
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Jan 2011
    Link to this post
    Hi Dan,

    There was a bug in our code that was casing the issue. I fixed the issue earlier today. The fix will be included in the Friday's build.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    07 Feb 2011
    Link to this post
    Hi Ivan,

    I am still seeing the issue with build 4.0.1141.0.  Any idea when this is going to fixed.

    thanks
    Dan
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Feb 2011
    Link to this post
    Hi Dan,

    I checked the code today with custom provider and I am not able to replicate this issue anymore. Also when you create a user you should create a ManagerInfo object for the user

    /newUser.ApplicationName = "/MyProvider";
    newUser.Comment = "";
    newUser.LastActivityDate = DateTime.UtcNow.AddDays(-1);
    var mi = new ManagerInfo();
    newUser.SetCreationDate(DateTime.UtcNow);
    newUser.LastLoginDate = DateTime.UtcNow;
    mi.ApplicationName = newUser.ApplicationName;
    mi.ManagerType = typeof(UserManager).FullName;
    mi.ProviderName = "MyProvider";
    newUser.ManagerInfo = mi;
    users.Add(newUser);


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Dan
    Dan avatar
    28 posts
    Registered:
    16 Jun 2010
    11 Feb 2011
    Link to this post
    hi Ivan,

    Your code was helpful.  Looks like the missing piece was the ManagerInfo object.

    Thanks!
    Dan
15 posts, 0 answered