Even better: use solution 3, but create a view on the database and query the view instead.<div>I&#39;m not sure if it can be done it but I guess that a malicious user could trick mapserver and add a filter like &#39; OR 1=1 &#39; and in that case ALL features (including GROFT) will be shown.<br>
<br>HTH,</div><div>Umberto<br><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 1:09 AM, Gabe Codina <span dir="ltr">&lt;<a href="mailto:Gabe@agtrix.com">Gabe@agtrix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div lang="EN-AU" link="blue" vlink="purple"><div><p class="MsoNormal"><a name="134d46ec828e14c0__MailEndCompose"><span style="color:#1f497d">We do something similar here is how we implement your solution 3<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">    CONNECTIONTYPE PLUGIN<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">    PLUGIN &quot;.\msplugin_mssql2008.dll&quot;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">    CONNECTION &quot;server=SERVER\MSSQL;uid=USERID;pwd=PASSWORD;database=DATABASE;Integrated Security=false&quot;<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">    DATA &quot;gExtent FROM (</span><span lang="EN-US">SELECT * FROM tm_points WHERE type!=’GRØFT’</span><span style="color:#1f497d">)AS FOO USING UNIQUE [iId] USING SRID=4326&quot;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">Note the connection string needs to access your MSSQL Instance and the plugin dll  must be available the format of the data statement lets you put quite a complex SQL statement inside the ()s.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><div><p class="MsoNormal"><span style="color:#1f497d">Gabe Codina<u></u><u></u></span></p></div><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Hawk AA<br>
<b>Sent:</b> Friday, 13 January 2012 3:24 AM<br><b>To:</b> <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br><b>Subject:</b> [mapserver-users] Mapserver Layer Filter<u></u><u></u></span></p>
</div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span lang="EN-US">Hi there, Mailing List,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">We have a customer that wants their maps to be published online, but some of the features is confidential and should not be displayed.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">We have added following to the layer definition:<u></u><u></u></span></p><p class="MsoNormal"><span lang="NO-BOK">FILTER (&#39;[type]&#39; != &quot;GRØFT &quot;)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">It works, the features with type GRØFT are not showed in the map.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">However, we have a window that let the user browse the data, and it will be possible to access the features of type GRØFT. When you press “show in map”, the JavaScript clients triggers a WFS request with a filter asking for elements with the current ID. By doing this, WFS omits the LAYER FILTER definition, so the element can be showed in the map, even if it is of type GRØFT. I need a way to make sure the WFS can’t deliver any data of type GRØFT.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">I’ve seen three possible solutions:<u></u><u></u></span></p><p><u></u><span lang="EN-US"><span>1.<span style="font:7.0pt &quot;Times New Roman&quot;">       </span></span></span><u></u><span lang="EN-US">We have a service that automatically converts uploaded MapInfo *.TAB-files to SHP. If I am correct, I could use the “-where”-argument on the ogr2ogr to filter data and only get features which does not have type GRØFT. I hope I do not have to do this, since debugging and developing a windows service is quite tricky.<u></u><u></u></span></p>
<p><u></u><span lang="EN-US"><span>2.<span style="font:7.0pt &quot;Times New Roman&quot;">       </span></span></span><u></u><span lang="EN-US">Add additional filter values to the WFS query. I could also define the types not to show in the JavaScript, and let the application automatically add &lt;PropertyIsNotEqualTo&gt;-tags to the AJAX query. This would be less secure, and I need to define types not to show at two places.<u></u><u></u></span></p>
<p><u></u><span lang="EN-US"><span>3.<span style="font:7.0pt &quot;Times New Roman&quot;">       </span></span></span><u></u><span lang="EN-US">The best solution in my eyes is to let the magic happen in the MAP-file, and that is mostly why I am posting here. Is there a way to add a query to the Layer Data definition, like you do if you are querying a MSSQL database? I can imagine a syntax like this:<br>
CONNECTIONTYPE OGR<br>CONNECTION &quot;TM_Nett/TM_Points&quot;<br>DATA &quot;SELECT * FROM tm_points WHERE type!=’GRØFT’”<br>It does not seem to work.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Any suggestions, especially regarding the third solution?<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Best regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Håkon Åmdal<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p></div></div></div>
</div><br>_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
<br></blockquote></div><br></div>