11 Replies Latest reply on Aug 24, 2018 7:22 AM by KocPawel

    vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role

    bdamian Hot Shot
    vExpert

      Hi all,

       

      In vRA 6.x, a user with support role couldn't see the "Properties" Tab for a VM in the Reconfigure Screen. Now, in vRA 7.3 they can see this tab.

       

      Is there any way to hide that tab?

       

      Thanks,

      D.

        • 1. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
          daphnissov Guru
          vExpertCommunity Warriors

          Not any supported way of doing so. I'm not even sure you could hack it into submission.

          • 2. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
            jasnyder Expert
            vExpert

            Agree with daphnissov there is no supported way to do this, but as it turns out you can hack it into submission:

             

             

            It's all hackable.  But just because you can, does that mean you should?

             

            If you're interested I can provide details.  Let me know.

            • 3. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
              bdamian Hot Shot
              vExpert

              Hi Justin,

               

              I am interested in the hack. As long as we don't lose official support.

               

              Thanks a lot

              D.

              • 4. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                daphnissov Guru
                Community WarriorsvExpert

                I'd be interested to know, just so I can file it away in the folder "things you can but shouldn't do"

                • 5. Re:vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                  Luke Novice

                  Dennis has this on his Blog: http://www.automate-it.today/advanced-options-vrealize-automation-hide-properties-snapshots-tab/

                  I have added a comment today which shows exactly where to add the bit of code....I have copied my comment below in quotes:

                  I would also like to hide various tabs on the request such as Storage etc but this is vRA content not IaaS. Does anyone know what file and code needs editing to hide tabs on the VM request?

                  I had the exact same problem as I am running vRA 7.3 and this blog had the line “…so the line looks like this” but had no indication of the code.

                  Luckily I have a dev environment so was able to ‘play’. It is a parameter of the tag, so…

                  <dxtc:TabPage Text="” Name=”Properties”>

                  becomes…

                  <dxtc:TabPage Text="” Name=”Properties” ClientVisible=False>

                  Notice ClientVisible is set with…

                  ClientVisible=False

                  not…

                  ClientVisible=”False”

                  The parameter has to be Boolean, not String.

                  • 6. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                    jasnyder Expert
                    vExpert

                    To make the modification I put a screenshot of in my previous post to this thread, I added some import directives at the top of the C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\EditVirtualMachine.aspx file on the IaaS server hosting the vCAC server component (under the first <%@ Page line) so I could put some custom code in to make a decision about hiding the tab if you're not a manager (being unable to change the code behind the ASPX pages, this is a hack to change it on the "front side"):

                     

                    <%@ Import Namespace="System.Reflection" %>

                    <%@ Import Namespace="DynamicOps.Web.Leases" %>

                    <%@ Import Namespace="System.Security.Claims" %>

                     

                    Then I added the following code block, directly underneath the Javascript code block near the top:

                     

                    <%

                            EditVirtualMachine evm = this;

                            FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);

                            string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;

                            bool admin = false;

                            bool support = false;

                            Type t = this.GetType().BaseType;

                     

                    var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);

                     

                            foreach(string r in Roles.GetRolesForUser(User.Identity.Name))

                            {

                                if(r == groupName + "|My business group Administration User Interface") admin = true;

                                if(r == groupName + "|Operate On Behalf Of User") support = true;

                            }

                     

                            bool show = admin || (!admin && !support);             

                     

                            this.MachineRecord.GetTabPage("Properties").Visible = show;

                            this.MachineRecord.GetTabPage("Properties").ClientVisible = show;

                       

                    %>

                     

                    It will show the tab if you own the machine or are an admin, but not if you're support.  It can be made so only admins can see it by changing the "bool show = admin || ..." line to just "bool show = admin;".  It will also be in effect on both new submissions and reconfigurations.  I was going to add some logic to account for this, but didn't get to it.

                     

                    Posting this in case it's helpful to anyone, but it is important to note that I am sure this is not supported and you should be sure to test it thoroughly in your environment before making the change.

                     

                    This was created in/for vRA 7.3, but would most likely work in 7.x

                    • 7. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                      Luke Novice

                      Nice! thanks

                       

                      I will try that out because if it does hide on requesting VMs too that solves what I was looking for

                       

                      To try and do the reverse, will...

                       

                      this.MachineRecord.GetTabPage("Properties").ClientVisible = hide

                       

                      work instead of...

                       

                      this.MachineRecord.GetTabPage("Properties").ClientVisible = show?

                      • 8. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                        Luke Novice

                        jasnyder There is no "VirtualMachineLeases.aspx" file in "C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\"

                        • 9. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                          jasnyder Expert
                          vExpert

                          show is a boolean variable set to the value admin (user is a member of the group manager role) or - user is both not a manager and not in the support role - i.e. a support user. 

                           

                          If either of those cases is true, show is true and then it shows the object.

                           

                          If you just want to hide it, this.MachineRecord.GetTabPage("Properties").ClientVisible = false;  would do the trick.

                           

                          I have noticed that on the component, this will hide it for regular users, but for admin and support users will not hide it.  On the deployment, it does hide it for all, and on the machine inspection or reconfigure, it will hide it for all.

                           

                          Something about that initial request form overrides the properties tab for some users on properties as well as storage.  I'll keep working on it and let you know if I can figure something out.

                          • 10. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                            jasnyder Expert
                            vExpert

                            Sorry, typo on my part, I edited the post, but it is supposed to be the C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\EditVirtualMachine.aspx file.

                            • 11. Re: vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role
                              KocPawel Hot Shot

                              Hello,

                              I tried to copy that code to file but I have error. Can anyone help ? My file looks like:

                              <%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="true" Inherits="DynamicOps.Web.Leases.EditVirtualMachine" CodeBehind="EditVirtualMachine.aspx.cs" uiCulture="auto" %>

                              <%@ Register TagPrefix="vmps" TagName="PropertyBag" Src="~/UserControls/PropertyBag.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="HardwarePanel" Src="~/UserControls/HardwarePanel.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="EbsStorage" Src="~/UserControls/EbsStorageGrid.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="ListBoxPicker" Src="~/UserControls/ListBoxPicker.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="LoadBalancersGrid" Src="~/UserControls/LoadBalancersGrid.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="Network" Src="~/UserControls/NetworkGrid.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="Storage" Src="~/UserControls/StorageGrid.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="SnapshotManager" Src="~/UserControls/SnapshotManager.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="ComponentMachinesGrid" Src="~/UserControls/ComponentMachinesGrid.ascx" %>

                              <%@ Register TagPrefix="vmps" TagName="SecurityObjects" Src="~/UserControls/SecurityObjects.ascx" %>

                               

                              <%@ Import Namespace="System.Reflection" %>

                              <%@ Import Namespace="DynamicOps.Web.Leases" %>

                              <%@ Import Namespace="System.Security.Claims" %>

                              <%

                                      EditVirtualMachine evm = this;

                                      FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);

                                      string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;

                                      bool admin = false;

                                      bool support = false;

                                      Type t = this.GetType().BaseType;

                              var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);

                               

                                      foreach(string r in Roles.GetRolesForUser(User.Identity.Name))

                                      {

                                          if(r == groupName + "|My business group Administration User Interface") admin = true;

                                          if(r == groupName + "|Operate On Behalf Of User") support = true;

                                      }

                               

                                     bool show = admin || (!admin && !support);             

                                      this.MachineRecord.GetTabPage("Properties").Visible = show;

                                      this.MachineRecord.GetTabPage("Properties").ClientVisible = show;

                              %>

                              <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server">

                              ..............................

                              <%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="true" Inherits="DynamicOps.Web.Leases.EditVirtualMachine" CodeBehind="EditVirtualMachine.aspx.cs" uiCulture="auto" %>
                               
                              <%@ Register TagPrefix="vmps" TagName="PropertyBag" Src="~/UserControls/PropertyBag.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="HardwarePanel" Src="~/UserControls/HardwarePanel.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="EbsStorage" Src="~/UserControls/EbsStorageGrid.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="ListBoxPicker" Src="~/UserControls/ListBoxPicker.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="LoadBalancersGrid" Src="~/UserControls/LoadBalancersGrid.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="Network" Src="~/UserControls/NetworkGrid.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="Storage" Src="~/UserControls/StorageGrid.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="SnapshotManager" Src="~/UserControls/SnapshotManager.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="ComponentMachinesGrid" Src="~/UserControls/ComponentMachinesGrid.ascx" %>
                              <%@ Register TagPrefix="vmps" TagName="SecurityObjects" Src="~/UserControls/SecurityObjects.ascx" %>
                               
                              <%@ Import Namespace="System.Reflection" %>
                              <%@ Import Namespace="DynamicOps.Web.Leases" %>
                              <%@ Import Namespace="System.Security.Claims" %>
                              <%
                                      EditVirtualMachine evm = this;
                                      FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);
                                      string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;
                                      bool admin = false;
                                      bool support = false;
                                      Type t = this.GetType().BaseType;
                              var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);
                               
                                      foreach(string r in Roles.GetRolesForUser(User.Identity.Name))
                                      {
                                          if(r == groupName + "|My business group Administration User Interface") admin = true;
                                          if(r == groupName + "|Operate On Behalf Of User") support = true;
                                      }
                               
                                     bool show = admin || (!admin && !support);             
                                      this.MachineRecord.GetTabPage("Properties").Visible = show;
                                      this.MachineRecord.GetTabPage("Properties").ClientVisible = show;
                              %>
                               
                               
                              <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server">