Check digital signature/user's current role with code - InfoPath Dev
in

InfoPath Dev

Check digital signature/user's current role with code

Last post 02-28-2008 03:03 PM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-04-2008 09:09 AM

    • KoopLaFez
    • Not Ranked
      Male
    • Joined on 01-22-2008
    • San Diego, CA
    • Posts 21

    Check digital signature/user's current role with code

    I'm currently using rules to direct form submission when the user click's the submit button.  I can see, however, that I am going to need more flexibility in controlling what happens when the form submits, so I need to convert these rules into code.  One of conditions I am using involves checking whether a certain set of signable data has been signed.  How do I do this in code?  Also, how do I check a user's current role using code?

  • 02-14-2008 12:32 PM In reply to

    Re: Check digital signature/user's current role with code

    There is a SignedDataBlocks collection that you can look into Each SignedDataBlock in the collection has a Signatures property which returns a collection of the signatures on that block.

    The XDocument object has a Role property that you can look at.

  • 02-14-2008 01:16 PM In reply to

    • KoopLaFez
    • Not Ranked
      Male
    • Joined on 01-22-2008
    • San Diego, CA
    • Posts 21

    Re: Check digital signature/user's current role with code

    Thanks Greg.  One other question.  Is the Role a single property or a collection?  The reason I ask is that I have some users that are in multiple roles.  When I use rules to determine which view they got on opening the form it only considers (I think) the first role that the user belongs to as it is listed on the user roles window.  What I'd like to do is build a function that I can give the name of a role to, have it cycle through all the roles that the current user belongs to, then return true if the user belongs to that role or false if the user doesn't.  Is that possible?

  • 02-19-2008 10:59 AM In reply to

    Re: Check digital signature/user's current role with code

    The Role property is a single value.

    InfoPath walks through the role evaluation top-down. The first matching role is the one assinged. Therefore, you must always make sure to put the least restrictive roles at the top or users that are in more than one role will never get their full rights on the form.

    In order to cycle through all existing roles, you'll have to write some code to do that. There should be a programmatic way to get to the roles as I believe they are stored in the manifest. Otherwise, you'll need to just manually account for each role in the code.

  • 02-27-2008 04:10 PM In reply to

    • KoopLaFez
    • Not Ranked
      Male
    • Joined on 01-22-2008
    • San Diego, CA
    • Posts 21

    Re: Check digital signature/user's current role with code

    One more question:

    I was reading about the Role property in the help file and it said that it could be used to either read or set the current user's role.  I used it to change the user's role within a form and it worked (I used a button that displayed an alert with the user's current role, which was the default role, changed the role, then displayed another alert to show the updated role).  However, when I submitted this form to an email address and opened it up, the role and reverted back to the default.

    I looked around the help file some more and found the roles element, which looks promising, but I don't know how to manipulate it.  So my question is:

    1.  If I change the user's role in the membership element of the roles element, will this change permanant (i.e. would it be the same as if I changed the user role manually)?

    2.  If so, how do I go about about changing the user's role in the membership element?

    I know I'm going to have to use the username element to do this, which means I'm going to have to get the current user's name.  I tried the Active X method explained here:http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=173.  Once I have this information, though, how do I go out, find the username element with the correct user name, and update it to reflect the new role?

    OK, I guess that was a few questions, but any input you could provide would be greatly appreciated.

  • 02-28-2008 03:03 PM In reply to

    Re: Check digital signature/user's current role with code

    The User Role is evaluated when the form is opened. It is not stored anywhere and is not persisted across sessions.

    You can either use code to set the user role (OnLoad) or you can make sure roles are order least to most restrictive when you create them. Roles let you use names and groups... take that into account.

    It is sounding like you want to take full control of the role assignment though... this means you will need to use code and write whatever you need to in order to make the appropriate evaluation. The only property you need to worry about is the Role property itself. The membership stuff you are talking about <xsf:roles><xsf:membership/></xsf:roles> is all part of the manifest and is generated via the Tools | User Roles menu command. You cannot modify this, nor should you attempt to, with your form code. It is generated during the design phase of your template.

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.