Select to view content in your preferred language

Login Screen for the Flexviewer

41145
121
03-15-2011 10:52 AM
andrewj_ca
Frequent Contributor
Just posted some code for a Flexviewer login screen.  I hope somebody can get some use from this.

http://www.arcgis.com/home/item.html?id=baebcaf317994d63902bc9735c0657e0
Tags (2)
0 Kudos
121 Replies
MatthewGerbrandt
Emerging Contributor
Hello, everyone.  I was hoping that someone could show me the XML syntax should look like in the users.xml file so that I can list more than one user. For some reason, this is really throwing me for a loop.

Thanks a million!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
GIS Tech,

   Sure here it is:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="user_validation" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="user_validation">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="uid" type="xs:long" minOccurs="0" />
                <xs:element name="username" type="xs:string" minOccurs="0" />
                <xs:element name="password" type="xs:string" minOccurs="0" />
                <xs:element name="firstname" type="xs:string" minOccurs="0" />
                <xs:element name="lastname" type="xs:string" minOccurs="0" />
                <xs:element name="code" type="xs:string" minOccurs="0" />
                <xs:element name="email" type="xs:string" minOccurs="0" />
                <xs:element name="phone" type="xs:string" minOccurs="0" />
                <xs:element name="creation" type="xs:dateTime" minOccurs="0" />
                <xs:element name="configfile" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <user_validation>
    <uid>1</uid>
    <username>Blah Blah</username>
    <password>Pa$$w0rd</password>
    <firstname>first</firstname>
    <lastname>last</lastname>
    <creation>2011-09-05T00:00:00-05:00</creation>
  </user_validation>
  <user_validation>
    <uid>2</uid>
    <username>blah blah</username>
    <password>Pa$$w0rd</password>
    <firstname>first</firstname>
    <lastname>last</lastname>
    <creation>2011-09-05T00:00:00-05:00</creation>
  </user_validation>
</NewDataSet>

Don't forget to click the top arrow (promote).
As shown in the below graphic:
0 Kudos
MatthewGerbrandt
Emerging Contributor
Thank you very, very much Robert!
0 Kudos
MattPohl
Frequent Contributor
Hi,

I have managed to create an ASP.NET wrapper application for my flex viewer application. Users and user access to different basemaps is built into SQL tables in the GIS database, there is a helpdesk function where 1st line suppport team can edit/create users and manage their access to basemaps without developer intervention. Passwords are encrypted by the .net app before being written to the database. This was designed for intranet use only.

Once a user is verified, they are presented with a choice of basemaps to load for the flexviewer app (they can only choose one, but may be entitled to see several). The map url they choose is then passed from the .net application to the flex viewer by using URL params. The flex viewer is actually embedded in an aspx page that sits within the .NET application project. There are also some code changes you need to make to the flex viewer out-of-the-box code to enable it to read the map url passed from the .net application.

There is plenty of scope to take what I have created and extend it / edit it to do other user specific processing in the flex application (ie load certain config files for particular users).

If anyone is interested I can make  the .NET code available together with the stored procedures for creating the authorisation tables in SQLServer, but I would suggest that non-technical users and people with zero .NET/ SQL experience would maybe find this a little beyond their capability and should consult their development team. There is probably a much neater way to do the user authentication by using the built in .NET API's for user/role authorisation. However in our case we needed to be able to manage users who are outside the company and have no windows domain accounts with us, but are able to access our intranet and this was the path of least resistance.

Also please note, to make the application work properly, there are changes that need to be made at the flex end in order for the URL params passed from .NET wrapper to be read. There is definitely scope for this code to be played with to enable different configs to be loaded for different users or any other user specific actions to be executed in the flex application based on URL parameter info passed through.


Hi Graham,

I would be very interested in seeing your code for this, it sounds great. This is similar to an ASP.NET app I am currently working on. I am also curious on the changes needed at the flex end for the URL parameters. You can reach me at mattp@teamworksintl.net with any questions/thoughts

Thanks in advance,

Matt
0 Kudos
JosephAccardi
Regular Contributor
Before I put in the effort to create this customized log-in screen, which sounds like a great tool, does it have the intelligence to only show the secured service layers that the logging-in user has permissions to? I can secure my entire site using IIS, but (to my knowledge) this method lacks the ability to query out service layers based on user permissions. On the other hand, I can secure my services using Server Manager's Identity Store, but it also lacks the ability to create one log-in pop-up and not show an error for services that aren't mapped due to permission restrictions. If this customized log-in screen can do this I'm definitely willing to ditch the Flex Viewer application that I'm currently using and work my way through the API for Flex world.

Thanks in advance.
0 Kudos
StephAllen
Deactivated User
Greg,

   Yes changing it to visible.Login="false" does work as a workaround but If you are like me and want to load a specific Config.xml file based on the user that logs in then that is not a feasible workaround.


Hi Robert,
I've been trying to figure out how to load a specific Config.xml based on the user that logs in... but have been unsuccessful.  How did you do this? Please help!
Thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Steph,

   The name of the config.xml is returned from the ASP.net webservice when a user logs in and that is then used by the index.mxml file to load the proper config.xml in the viewer. I have no time to walk anyone through the code or steps but the necessary code and changes to the viewer are available at this url:

http://gis.calhouncounty.org/devsummit2012
0 Kudos
StephAllen
Deactivated User
Steph,

   The name of the config.xml is returned from the ASP.net webservice when a user logs in and that is then used by the index.mxml file to load the proper config.xml in the viewer. I have no time to walk anyone through the code or steps but the necessary code and changes to the viewer are available at this url:

http://gis.calhouncounty.org/devsummit2012


Thanks, I will have a look at it and see what I can do! Much appreciated 🙂
0 Kudos
BillKing1
New Contributor
Just posted some code for a Flexviewer login screen.  I hope somebody can get some use from this.

http://www.arcgis.com/home/item.html?id=baebcaf317994d63902bc9735c0657e0

Hi,I found that I can't download the code for Login Screen for the Flexviewer which is belong to mcnaughty79 ,so is there anybody could do me a favor to sent it to my email:gis.jzx@gmail.com,thank you very very much!
0 Kudos
StephAllen
Deactivated User
Thanks, I will have a look at it and see what I can do! Much appreciated 🙂


Robert,

Thanks again for the files. I managed to get Andrew's original Login to work but I am stuck on this one. I continue to get "Internal Database Error", no matter what I try in either IIS or the index.mxml.

I simplified the index.mxml to only utilize username and password as I didn't need the rest with regards to District, Dates, etc. I am SO CLOSE to getting this launched! Below is the portion where I 'think' is hitting the road-block. If it is something too complex and/or you don't have time, I will have to go another route. I would appreciate your help if you can???

// The functions to connect to the WebService for user validation
protected function submit_clickHandler(event:MouseEvent):void
{
validate_user_proxy(); //use this to call service
}

protected function validate_user_proxy():void
{
var proxyService:String= "validatedUserInfo";
var ws:WebService = new WebService;
ws.wsdl ="http://servername/ArcGIS_Security2/Service.wsdl";
ws.loadWSDL();
ws[proxyService].addEventListener(mx.rpc.events.FaultEvent.FAULT,validationFaultHandler);
ws[proxyService].addEventListener(mx.rpc.events.ResultEvent.RESULT,vsResultHandler);
ws.getOperation(proxyService).send("PrivateWebGIS",userName.text,passWord.text,"username","password","configfile");
}

public function validationFaultHandler(event:mx.rpc.events.FaultEvent):void
{
this.currentState = "Login";
lblStatus.text="Internal database error.";
}

//Set the public vars based on the users choices
public function vsResultHandler(event:mx.rpc.events.ResultEvent):void
{
var configFile:String = event.result as String;
if(configFile != ""){
var outArray:Array = configFile.split(",");
usrConfigfile = outArray[0];
usrName = outArray[1] + " " + outArray[2];
//if(dRangeChk.selected){
//usrBDate = DatePicker1.selectedDate;
//usrEDate = DatePicker2.selectedDate;
//}
//usrDistrict = (DistrictCb.selectedIndex > -1) ? String(DistrictCb.selectedItem) : "None";
//usrCrimeType = (CrimeTypeCb.selectedIndex > -1) ? String(CrimeTypeCb.selectedItem) : "None";
//usrMuni = (MuniCb.selectedIndex > -1) ? String(MuniCb.selectedItem) : "None";
currentState = "Viewer";
}else{
currentState = "Login";
lblStatus.text="Invalid login.";
}
}
]]>
</fx:Script>
0 Kudos