Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Integrate Gallery Server with DotNetNuke
Richard
#1 Posted : Monday, 6 August 2007 6:19:29 AM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

Hi,

How can i retrieve (in code) the current username from a logged-in user?

Or

Can i change the application name to 'DotNetNuke' so that GSP will use the DNN users already in the database?

Richard
Richard
#2 Posted : Monday, 6 August 2007 7:52:12 AM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

half the answer:

Private Function getUser() As String
Dim username As String
username = HttpContext.Current.User.Identity.Name
Return username
End Function

Roger Martin
#3 Posted : Tuesday, 7 August 2007 12:34:29 PM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

Yes, you should be able to change the application name as you suggest. Remember to do it for all three membership elements: <roleManager>, <membership>, and <profile>. If the membership is in another database, you should also update the connection string for each of those.

I haven't done thorough testing here, so I'm curious how your experience goes. One potential trouble area is that while GS might recognize a user after you make the change, it won't know what album permissions to give the user, and it will default to no access. Gallery Server stores permissions such as "Edit media object" and "Delete album" in the table gs_Role. The table gs_Role_Album stores the list of albums each role applies to (permissions cascade down to all child albums, so only the top album ID is stored). In both tables the RoleName field must correspond to a matching ASP.NET role.

Two things to note here:

1. There is startup code that runs in GS that checks to make sure there is a matching record in gs_Role for each ASP.NET role, but the code doesn't give the role any permissions (security concerns, you know).

2. The solution is to manually open gs_Role and give one of the roles Admin access by setting the AllowAdministerSite field to true (1).

Whatever user(s) belong to this role should now have admin access to GS. (You may have to restart IIS or "touch" the config file to force GS to reload the data.)

Let us know how this goes, Richard.

Cheers,
Roger
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Richard
#4 Posted : Tuesday, 7 August 2007 8:54:51 PM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

Looks like that's not going to work.

installed a clean DNN
installed a clean GSP, using the same database
changed the application names in the web.config, so that GSP uses the same name

GSP starts fine, but the login crashes.

A look in the aspnet_membership table shows that GSP stores the password in clear text, and DNN encrypted. GSP uses password format 0, DNN password format 2....

Logging in into GSP results in the error:
You must specify a non-autogenerated machine key to store passwords in the encrypted format. Either specify a different passwordFormat, or change the machineKey configuration to use a non-autogenerated decryption key.

So it looks this will not work, until GSP uses the same format.

Richard
Roger Martin
#5 Posted : Wednesday, 8 August 2007 1:15:40 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

I don't think you've encountered a serious obstacle. The settings you described are all specified in web.config, so you should be able to modify them to match DNN.

Look for this section in web.config:

<membership defaultProvider="SqlMembershipProvider">
<providers>
<clear/>
<add applicationName="Gallery Server Pro" connectionStringName="GalleryServerDbConnection" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="2" requiresQuestionAndAnswer="false" passwordFormat="Clear" enablePasswordReset="true" enablePasswordRetrieval="true" requiresUniqueEmail="false" maxInvalidPasswordAttempts="50" passwordAttemptWindow="10" name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>

I assume DNN has a similar section in its web.config. Modify the GSP web.config to match DNN's web.config. You should be able to change most of those settings without breaking GSP. The only exception I can think of is, if you specify requiresQuestionAndAnswer="true", I didn't add code to the create user wizard to ask for a question/answer.

Cheers,
Roger
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Richard
#6 Posted : Wednesday, 8 August 2007 7:06:01 AM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

Thanks for your help Roger, this is the whole story to get it working:



How to change GalleryServer pro 2.0 to use DotNetNuke logins

GSP and DNN use the same authorization. This makes it possible to change the GSP configuration that it will use the DotNetNuke users. No code modifications will be made, so updates will still work. All changes are made in the config files, and changing a few values in the users database.

In the web.config, search for ‘Application Name’ and ‘ApplicationName’ and change all from ‘Gallery Server Pro’ to ‘DotNetNuke’

Search in the dotnetnuke web.config for ‘machineKey’ and copy the tag. Mine was:

<machineKey validationKey="3DBAAD20ABB6CA7667A794D3D34D4E7C71C96B22" decryptionKey="FE365179B384769EF90B2C5943CA13F778FF0A35E6FED80E" decryption="3DES" validation="SHA1" />

Add this tag to the system.web section in the GSP web.config. GSP does not have one, but needs it now.
Like:

</connectionStrings>

<system.web>

<machineKey validationKey="3DBAAD20ABB6CA7667A794D3D34D4E7C71C96B22" decryptionKey="FE365179B384769EF90B2C5943CA13F778FF0A35E6FED80E" decryption="3DES" validation="SHA1" />

After that, you already will be able to login, but – as Roger said – you have exactly access to… nothing.

To give yourself admin rights, dive into your database and do some hacking with Management Studio.

Go to the aspnet_Users table, and find the UserID (a GUID – long line of characters) of your DOTNETNUKE administrator. Open the aspnet_Roles table, and find the System Administrator role FROM DOTNETNUKE. Most likely you’ll have 2 of them, but one is the GSP admin. To find the correct one, open the aspnet_Applications table and see what ID DotnetNuke is using.

Now – finally – open the dotnet_UsersInRoles table and add a new record, with the userID from the dotnetnuke admin, and the roleID from the DotNetNuke System Administrator. (No – it is not there yet – dotnetnuke does not use this table itself)

After that make sure the System Administrator role is in the gs_Role table with the appropriate permissions (allowAdministerSite=true etc), and that the System Administrator role is in the gs_Role_Album table, pointing to album 1

After all this you can login to GSP with your DotNetNuke admin account, and you will be admin in GSP too.

YAY!

Now all thats left is a page that detects that a user is already logged-in in DNN, and performs a auto-login in GSP. Then from DNN (using the Iframe module) we can point to this auto-login page and the users have all GSP power in DNN. This will be a major publicity boost for GSP, since all galleries i could find for DNN suck big time.

Richard

Roger Martin
#7 Posted : Wednesday, 8 August 2007 8:14:26 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

That's great news! Thanks for the writeup, Richard.

You said you changed all instances of the "Gallery Server Pro" application name to "DotNetNuke". This implies you changed it in the connection string, too:

<connectionStrings>
<add name="GalleryServerDbConnection" connectionString="Data Source=(local);Initial Catalog=GalleryServerPro;Integrated Security=true;Application Name=Gallery Server Pro"
providerName="" />
</connectionStrings>

It seems to me that this change is not necessary. Can you verify whether that was required?

Cheers,
Roger
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Richard
#8 Posted : Wednesday, 8 August 2007 9:46:43 PM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

Most likely. Will try on my test site.

Can you pass me some code that will perform a LoginUser(username) ?
(yup - without the password)

Picking up the - already logged-in - user from DNN works (using the dnn dll), so this is the only step missing.

Richard
Roger Martin
#9 Posted : Thursday, 9 August 2007 12:50:11 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

The following code worked on a test page in Gallery Server. You have to programmatically retrieve the password in order to authenticate. This technique won't work when the password is hashed, but I think it will work when it is encrypted, such as your case.

Code:
string userName = "admin";
MembershipUser user = Membership.GetUser(userName);
if (Membership.ValidateUser(userName, user.GetPassword()))
{
    FormsAuthentication.RedirectFromLoginPage(userName, false);
}


I couldn't find a method that simply does a login; the examples always combine the ValidateUser with the RedirectFromLoginPage method. With a little detective work you may find something a little cleaner. Remember you are dealing with the Membership API, not GS-specific code.

Cheers,
Roger
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Richard
#10 Posted : Thursday, 9 August 2007 5:57:06 AM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

It works. But - we have to use 2 pages.
Since GSP is running in another application, the DNN login is empty there.

As example i put the username on the querystring, for live sites doing a hidden form post is advised, sending the username and password.
Using this concept example is an half open door.

A working example:

In Dotnetnuke, make a aspx page with:

Code:

Imports System.Collections
Imports System.Web.Security

Imports DotNetNuke

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim userName as string
                userName = GetUserName()

                Response.Redirect("http://localhost/GSPintegration/GSPLogin.aspx?u=" & userName)

End Sub

Public Shared Function GetUserName() As String
Dim mUser As DotNetNuke.Entities.Users.UserInfo
Dim username As String

mUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo
username = mUser.Username

Return username
End Function
End Class



In GSP, the page contains:

Code:

Imports System.Collections
Imports System.Web.Security

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim userName as string
userName = Request.Querystring("u")

if username <> "" Then
    Dim user as MembershipUser
    user = Membership.GetUser(userName)
    if Membership.ValidateUser(userName, user.GetPassword()) Then
                            FormsAuthentication.RedirectFromLoginPage(userName, false)
    End if
    Else
     'Not logged in
        Response.Redirect("default.aspx")
    End if
End Sub
End Class



This works fine, having GSP fully integrated in a DotNetNuke site.

Have fun!

Richard
Richard
#11 Posted : Thursday, 9 August 2007 6:13:34 PM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

The living proof



Okay, now who's gonna log me out? :-)
Roger Martin
#12 Posted : Sunday, 12 August 2007 11:39:54 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

Richard,

Can you share how you integrated Gallery Server into your site in regards to how you handled the master pages? I assume you retained the master pages Gallery Server is using, but somehow you embedded them into another page. Perhaps you can share what the ASPX code looks like for the screen shot you posted.

One of my highest priority post-2.0 features is to allow Gallery Server to be *easily* embedded in other web applications. I imagine the current use of master pages is making this a bit difficult at the moment.

Roger Martin
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Richard
#13 Posted : Sunday, 12 August 2007 9:33:03 PM(UTC)
Rank: Member

Joined: 3/08/2007(UTC)
Posts: 24
Location: Holland

Sure,

First: All modifications and tricks i use are done without changing the GSP database or code, to stay compatible with any future updates. So all changes can be made without much programming knowledge.

In DNN create a new page with an Iframe. Set the Iframe not to show it's container.
Point the iframe url to the auto-login page for GSP.

To have GSP show nicely in DNN, without the header, i modded the site masterpage.
Since we cannot remove the header (the code will start complaining that objects in the page are missing etc) another solution is to just hide that section. Then the code thinks the objects are still there, but we just don't show them in the end. Again - only not to touch the code itself.

To hide the header section, i've put it in a panel, and hide it. (Visible=false)

Here's my modded masterpage template:

Code:

<%@ Master Language="C#" AutoEventWireup="true" Codebehind="site.master.cs" Inherits="GalleryServerPro.Web.Master.site" MasterPageFile="~/master/global.master" %>
<%@ MasterType TypeName="GalleryServerPro.Web.Master.global" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="../uc/footer.ascx" TagName="footer" TagPrefix="uc1" %>
<%@ Register Src="../uc/albummenu.ascx" TagName="albummenu" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpContent" runat="server">
    <div id="wrapper">

        <div id="header_mod"><!-- MODDED -->

            <asp:Panel ID="pnlheaderloginandsearch" runat="server" CssClass="headerloginandsearch" Visible="False"> <!-- MODDED -->
                <asp:LoginView ID="LoginView1" runat="server" EnableViewState="false">
                    <LoggedInTemplate>
                        <asp:Panel ID="Panel1" runat="server" CssClass="headerloginview" EnableViewState="false">
                            <asp:LoginName ID="LoginName1" runat="server" meta:resourcekey="LoginName1Resource1" EnableViewState="false" />
                            <asp:LoginStatus ID="LoginStatus1" runat="server" meta:resourcekey="LoginStatus1Resource1" EnableViewState="false" OnLoggedOut="LoginStatus1_LoggedOut" />
                            &nbsp;<asp:HyperLink runat="server" NavigateUrl="~/myaccount.aspx" Text="My account" CssClass="fs" />
                        </asp:Panel>
                    </LoggedInTemplate>
                    <AnonymousTemplate>
                        <asp:Login ID="Login1" runat="server" DisplayRememberMe="False" Orientation="Horizontal" LabelStyle-CssClass="fss" TextBoxStyle-CssClass="loginwidth"
                            TextLayout="TextOnTop" TitleText="" meta:resourcekey="Login1Resource1" LoginButtonType="Button" LoginButtonStyle-CssClass="loginbutton"
                            EnableViewState="False" OnLoginError="Login1_LoginError" OnLoggedIn="Login1_LoggedIn">
                        </asp:Login>
                    </AnonymousTemplate>
                </asp:LoginView>
                <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch" CssClass="search">
                    <p>
                        <asp:TextBox ID="txtSearch" runat="server" CssClass="searchbox" />
                        <asp:Button ID="btnSearch" runat="server" CausesValidation="false" CssClass="searchbutton" PostBackUrl="~/search.aspx"
                            Text="<%$ Resources:GalleryServerPro, Master_Site_Search_Button_Text%>" ToolTip="<%$ Resources:GalleryServerPro, Master_Site_Search_Button_Tooltip%>" /></p>
                </asp:Panel>
            </asp:Panel>

            <asp:Panel ID="pnlTitle" runat="server" Visible="False"> <!-- MODDED -->
                <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="txtSearch" WatermarkCssClass="searchboxwatermark searchbox"
                    WatermarkText="Search">
                </cc1:TextBoxWatermarkExtender>
            <asp:PlaceHolder ID="phHeaderTitle" runat="server" EnableViewState="false" />
            </asp:Panel>

        </div>

        <uc1:albummenu ID="Albummenu1" runat="server" />
        <asp:ContentPlaceHolder ID="cpNavigation" runat="server" />
        <div id="content" runat="server" class="content">
            <noscript>
                <p class="msgwarning">
                    <asp:Literal ID="litNoScript" runat="server" Text="<%$ Resources:GalleryServerPro, Msg_NoScriptDefaultText%>" EnableViewState="false" /></p>
            </noscript>
            <asp:ContentPlaceHolder ID="cpContent" runat="server">
            </asp:ContentPlaceHolder>
            <uc1:footer ID="Footer1" runat="server" />
        </div>
    </div>
</asp:Content>



Besides the DNN integration and auto-login i also implemented:

Album and object ownership (using triggers on the gsp tables)
Every owner his own name, copyright and weblink on every photo
Windows management application for albums and user management (under development)

The windows applications are strictly for the site owner, to have a much more powerful tool for his management.
Roger Martin
#14 Posted : Monday, 13 August 2007 12:22:48 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

Thanks, Richard. That's good info and will help a lot of people.

Cheers,
Roger Martin
Roger Martin
Creator and Lead Developer of Gallery Server Pro
elizas
#15 Posted : Monday, 29 March 2010 10:30:00 PM(UTC)
Rank: Newbie

Joined: 29/03/2010(UTC)
Posts: 1
Location: India

Problem
If we are using watermark extender in a textbox, and also are trying to set the value of TextBox using JavaScript or jQuery, the text takes the format of watermarkCssClass style of that watermark extender .
e.g:
$('#textboxId').val("My Text");

For instance, if we set the watermark style as italic and color as gray , the text is always shown in gray italic and also behaves like a watermark text.
Solution
Call get_Text and set_Text methods of TextBoxWatermarkExtender to support client-side script access to the text in a watermarked text box.
Implementation

Lets take a text box with id "txtCity"
And watermarkExtender whose id is : “watermarkExTxtCity” , target id is : “txtCity” , behaviour id is : “behTxtCity” , watermark text= “Select City”

Now inside the script tag :
<script type="text/javascript" >
-
-
//Find the watermark extender using behaviour id refers to city text box
$find("behTxtCity" ).set_Text("My Text" );

//Similarly we can use get_Text() to take the value .
-
-
-
</script>
Guest
#16 Posted : Sunday, 23 May 2010 10:22:45 PM(UTC)
Rank: Guest

Joined: 2/08/2007(UTC)
Posts: 70

I have a situation that I would appreciate some assistance with.

I have a dNN application.

In the dnn application I have included and Iframe on one of the pages. In this there is a multi view.

on the first view the client selects his products that he would like to purchase. on confirmation the clioent clicks a button "order"

this then activates the second view in the multi view and populates the page with the clients order. this is working fine.

However I would like it to populate the clients details in the order form based on the client that is logged in.

I do not know if this makes any sense, this is rather urgent so I would appreciate any response.
Roger Martin
#17 Posted : Monday, 24 May 2010 12:37:51 AM(UTC)
Roger Martin

Rank: Administration

Joined: 3/08/2007(UTC)
Posts: 3,298
Location: Fort Atkinson, WI

This seems to be a DNN question, not a GSP one. I advise you try the DNN forums.
Roger Martin
Creator and Lead Developer of Gallery Server Pro
Rss Feed  Atom Feed
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.