How to override full name

You know, at the beginning every IDM project is clear and ideal. Everything seems to work well in the test environment, but as time goes by, the deadline is close and your customer finds more and more special cases. These cases have to be part of the solution “somehow” and “quickly” and of course they are found just in production. In many cases the problem is that we have good but not 100{1acb01afcc33953bed28d92be9d735e579722d77ac7936fdfc467b8d28505288} correct HR data. Yes, you could say (in most cases): “this is not my problem” or this is “customer’s” problem and they need to fix the source data in HR… and yes, it WILL BE fixed, maybe in a day or a week or a month, but you need to do it “NOW” or “yesterday” (as usual). We are professionals, we can’t go live with the system, where client’s BIG BOSS (or CEO, …) has full name with a typo, without diacritics or without honorifics and so on. Before the IDM project, this data was not visible and not online or up-to-date. If you update it in midPoint, HR system will replace it with its own (bad) one upon next synchronization. So the question is, how to override full name (not only for) VIP persons?

It’s easy because you have the best open source IDM solution at hand. You can extend the schema, create new attribute “Override Full Name”, and also update generation of full name what you already have done in user object template. I will explain it in the next steps.

Step 1: Extend the User Schema

Create a new extension.xsd file in [midpoint-home]\schema\ directory with this content:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsd:schema elementFormDefault="qualified"
    targetNamespace="http://midpoint.evolveum.com/xml/ns/custom/blog/extension-1"
    xmlns:tns="http://midpoint.evolveum.com/xml/ns/custom/blog/extension-1"
    xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
    xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:complexType name="UserExtensionType">
    <xsd:annotation>
      <xsd:appinfo>
        <a:extension ref="c:UserType"/>
      </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="overrideFullName" type="xsd:string" minOccurs="0" maxOccurs="1">
        <xsd:annotation>
          <xsd:appinfo>
            <a:displayName>Override Full Name</a:displayName>
            <a:displayOrder>400</a:displayOrder>
            <a:help>Override Full Name calculated from Given and Family Name</a:help>
          </xsd:appinfo>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

 

(Or open your existing file and put the appropriate code fragment to it.) 

Step 2: Restart midPoint

Stop and start tomcat service to read the extension schema.

Step 3: Create User object template

Log in to midPoint, go to menu –> Configuration –> Import object –> Get objects from “Embedded editor”, paste the next code snippet and click “Import object” button.

<objectTemplate xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" oid="c0c010c0-d34d-b33f-f00d-777222222333" version="0">

  <name>Sample User Template</name>
  <mapping>
    <description>
      Property mapping.
      Defines how properties of user object are set up.
      This specific definition sets a full name as a concatenation
      of givenName and familyName.
      If overrideFullName is filled return this by default.
    </description>
    <strength>strong</strength>
    <source>
      <c:path>$user/givenName</c:path>
    </source>
    <source>
      <c:path>$user/familyName</c:path>
    </source>
    <source>
      <c:path>$user/extension/overrideFullName</c:path>
    </source>
    <expression>
      <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xsi%3Atype%3D%22c%3AScriptExpressionEvaluatorType%22%3E%0A%20%20%20%20%20%20%20%20%3Clanguage%3Ehttp%3A%2F%2Fmidpoint.evolveum.com%2Fxml%2Fns%2Fpublic%2Fexpression%2Flanguage%23Groovy%3C%2Flanguage%3E%0A%20%20%20%20%20%20%20%20%3Ccode%3E%0A%20%20%20%20%20%20%20%20%20%20if%20(!basic.isEmpty(overrideFullName))%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20overrideFullName%3B%0A%0A%20%20%20%20%20%20%20%20%20%20return%20givenName%20%2B%20'%20'%20%2B%20familyName%0A%20%20%20%20%20%20%20%20%3C%2Fcode%3E%0A%20%20%20%20%20%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
    </expression>
    <target>
      <c:path>$user/fullName</c:path>
    </target>
  </mapping>
</objectTemplate>

 

Enable new user object template in menu –> Configuration –> System –> Object policies –> Edit –> select Object type = “UserType”, Object template = “Sample User Template” –> click “Save” & “Save” button.

(If you already have user object template put/edit appropriate code snippet.)

Step 4: Fill in new extended property to verify functionality

Open existing user over menu –> List users –> click on existing user –> on tab “Basic”, at the end of line “Properties” click on “Show empty fields”, find new property “Override Full Name” and fill in the correct full name –> click “Save” button. Now you can see in the standard “Full name” property the correct property:

OverrideFullNameIgor

(or create a new user and fill Name, First name, Last name and Override Full Name)

With the same principles, you can override any other required attributes.

Enjoy your super work and excellent feedback from the customer, and do not forget to thank to midPoint and Evolveum by considering subscription and/or partnership.

…and don’t tell to your BIG boss how easy the solution this BIG HR problem has in midPoint and don’t hesitate to ask for rewards! 😉

Leave a Reply

Your email address will not be published.