Hi,<br>I have a similar difficulty.<br><br>In site.zcml, the role &#39;zope.Member&#39; is defined and a permission is granted:<br> &lt;role id=&quot;zope.Member&quot; title=&quot;Site Member&quot; /&gt;<br> &lt;grant permission=&quot;zope.View&quot;<br>
         role=&quot;zope.Member&quot; /&gt;<br><br>How can I assign a role to a principal who is created on the fly:<br>a_principal = zope.app.authentication.principalfolder.InternalPrincipal(login=tab[0].encode(&#39;utf-8&#39;), password=tab[1].encode(&#39;utf-8&#39;), title=a_title.encode(&#39;utf-8&#39;), passwordManagerName=&#39;SHA1&#39;)<br>
 a_auth_plugin = getUtility(zope.app.authentication.interfaces.IAuthenticatorPlugin, &#39;myAuthenticatorPlugin&#39;)<br>role_map = IPrincipalRoleManager(a_auth_plugin)           role_map.assignRoleToPrincipal(&#39;zope.Member&#39;, a_principal.login)<br>
a_auth_plugin[a_principal.title] = a_principal<br><br>I verify that the role is assigned:<br>            interaction =     zope.securitypolicy.zopepolicy.ZopeSecurityPolicy()<br> print interaction.checkPermission(a_principal, a_auth_plugin)<br>
&gt;&gt;&gt; True<br><br>But when I want to access the page defined below, it returns &#39;Unauthorized&#39;:<br>&lt;page<br>      name=&quot;login.html&quot;<br>      for=&quot;zope.app.folder.interfaces.IFolder&quot;<br>
      permission=&quot;zope.View&quot;<br>          layer=&quot;cdcadama.layer.ICdcadamaBrowserLayer&quot;<br>      class=&quot;.login.LoginAddForm&quot;<br>/&gt;<br><br>Thanks for your help<br>Simon<br><br><br><div class="gmail_quote">
On Tue, May 12, 2009 at 12:34 PM, Massimiliano della Rovere <span dir="ltr">&lt;<a href="mailto:massimiliano.dellarovere@gmail.com">massimiliano.dellarovere@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I had a similar problem.<br>
My mistake was that I forgot the application prefix in the<br>
<a href="http://event.principal.id" target="_blank">event.principal.id</a>. (so instead of user app.XYZ I used only XYZ, which<br>
was not found in the PrincipalFolder).<br>
<div><div></div><div class="h5"><br>
<br>
On Tue, May 12, 2009 at 12:18, Thierry Florac &lt;<a href="mailto:thierry.florac@onf.fr">thierry.florac@onf.fr</a>&gt; wrote:<br>
&gt; Le mardi 12 mai 2009,<br>
&gt;  paftek &lt;<a href="mailto:paftek@gmail.com">paftek@gmail.com</a>&gt; a écrit :<br>
&gt; ======================================================================<br>
&gt;&gt; I created a Role and a Permission affected to it :<br>
&gt;&gt; &lt;role id=&quot;app.User&quot; title=&quot;Utilisateur&quot; /&gt;<br>
&gt;&gt; &lt;permission id=&quot;app.Auth&quot; title=&quot;Utilisateur authentifié&quot; /&gt;<br>
&gt;&gt; &lt;grant permission=&quot;app.Auth&quot; role=&quot;app.User&quot; /&gt;<br>
&gt;&gt;<br>
&gt;&gt; My users are store in a PostgreSQL database, not in the ZODB.<br>
&gt;&gt; I use the Zope authentication system to return a PrincipalInfo when an<br>
&gt;&gt; user log in.<br>
&gt;&gt;<br>
&gt;&gt; I do not know how to assign my &quot;app.User&quot; Role to the Principal who<br>
&gt;&gt; log in. I tried the following, without success :<br>
&gt;&gt;<br>
&gt;&gt; @adapter(IAuthenticatedPrincipalCreated)<br>
&gt;&gt; def setPermission(event):<br>
&gt;&gt;     role_map = IPrincipalRoleManager(getSiteManager())<br>
&gt;&gt;     role_map.assignRoleToPrincipal(&#39;app.User&#39;, <a href="http://event.principal.id" target="_blank">event.principal.id</a>)<br>
&gt; ======================================================================<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; What do you mean when you say &quot;without success&quot; ?<br>
&gt; What do you get when you look at the &quot;@@grant.html&quot; view over your<br>
&gt; context ??<br>
&gt;<br>
&gt; Thierry<br>
&gt; --<br>
&gt; Chef de projets intranet/internet<br>
&gt; Office National des Forêts - Département Informatique<br>
&gt; 2, Avenue de Saint-Mandé<br>
&gt; 75570 Paris Cedex 12<br>
&gt; Tél. : 01 40 19 59 64<br>
&gt; Fax. : 01 40 19 58 85<br>
&gt; Mél. : <a href="mailto:thierry.florac@onf.fr">thierry.florac@onf.fr</a><br>
&gt; Web. : <a href="http://www.onf.fr" target="_blank">http://www.onf.fr</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Zope3-users mailing list<br>
&gt; <a href="mailto:Zope3-users@zope.org">Zope3-users@zope.org</a><br>
&gt; <a href="http://mail.zope.org/mailman/listinfo/zope3-users" target="_blank">http://mail.zope.org/mailman/listinfo/zope3-users</a><br>
&gt;<br>
_______________________________________________<br>
Zope3-users mailing list<br>
<a href="mailto:Zope3-users@zope.org">Zope3-users@zope.org</a><br>
<a href="http://mail.zope.org/mailman/listinfo/zope3-users" target="_blank">http://mail.zope.org/mailman/listinfo/zope3-users</a><br>
</div></div></blockquote></div><br>