[mapguide-users] Pulling USERNAME from MapGuide

Hidekazu Shimaji hshimaji at ybb.ne.jp
Tue May 29 23:43:23 EDT 2007


Sorry I have no idea about PHP.
I usually use asp.net.

Here is a very simple sample of the asp.net.
I hope this can be a help for you.

---LogOnPage.aspx
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="OSGeo.MapGuide" %>
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        //initialize settings
        MapGuideApi.MgInitializeWebTier(@"C:\Program
Files\Autodesk\MapGuideEnterprise2007\WebServerExtensions\www\webconfig.ini");
        //get user information from text boxes
        MgUserInformation userInfo = new MgUserInformation(txtUserName.Text,
txtPassword.Text);
        //keep the username in a session variable
        Session["MGUSER"] = txtUserName.Text;
        //create a mapguide session id
        MgSite site = new MgSite();
        site.Open(userInfo);
        string sessionId = site.CreateSession();
        //redirect
        string url =
"http://localhost/mapguide/mapviewerdwf/?WEBLAYOUT=Library%3a%2f%2fTest%2fLayouts%2fTestLayer.WebLayout&SESSION="
+ sessionId;
        Response.Redirect(url);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Log On Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        username:<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br />
        password:<asp:TextBox ID="txtPassword" runat="server"
TextMode="Password"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="MapGuide"
/></div>
    </form>
</body>
</html>
---

---TaskPanePage.aspx
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        //get the username
        string username = Session["MGUSER"].ToString();
        Response.Write(username);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Task Pane Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
    </div>
    </form>
</body>
</html>
---

Hidekazu


--- Rich Bauer <rdbauer at gmail.com> wrote:


---------------------------------
  For the work around, how would you go about keeping the username in aweb session and
passing it into a frame.  I have tried several things,but I can't seem to get it to work.  I
am using php and JS.

Thanks,
Rich

Hidekazu Shimaji wrote:  
Hello,I don't think it is possible to get a username which is logging in.Why don't you keep
the username in a web session at the log on page?I mean that you should post back first, then
redirect to the web layout.Regards,Hidekazu--- Rich Bauer <rdbauer at gmail.com> wrote:  
      
Hi all,I am new to this mailing list, so I don't know if this question has been asked before
(I also tried to find it in the archive with no success).  The question is I am trying to let
the "user" access the data intended for them. Example:  User "Bill" logs on using a log on
page and is taken to the weblayout and everything just fine.  Then when "Bill" tries to
access a command that creates a "Markup" using sample code I found on the internet, I want
"Bill" to be able to access his markup and not everyones.  In other words, I would like to
change the path from:Library://Markup/     to     Library://Bill/Markup/The only problem I am
having is getting the username, "Bill", into the string that is sent by the code.My thought
was using the $_REQUEST['USERNAME'] or something, but can't get it working.  By the way, the
user "Bill" is the user under the MapAdmin panel and that.  Any help would be nice. 
Thanks.Rich_______________________________________________mapguide-users mailing
listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users    
    
_______________________________________________mapguide-users mailing
listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users  
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 



More information about the mapguide-users mailing list