[midPoint] Scripted SQL Connector

Stephen Barker sbarker at illinois.edu
Wed Mar 16 17:16:29 CET 2016


Aha! Thanks so much for finding my error, I knew it was something I was 
doing incorrectly.

Thanks,
Stephen Barker
Senior Software Engineer - AITS
University of Illinois
sbarker at uillinois.edu
265-0942
--
"we tend to be masters of our own fate, the only thing that stops us 
from doing really cool things is time." -- Monty Oum

On 03/16/2016 11:15 AM, Pavol Mederly wrote:
> Hello Stephen,
>
> please replace *gen808:searchScript* start and end tags by
> *gen808:searchScriptFileName*. Currently,
> "/opt/midpoint/config/scripted_connectors/uic_iam_scripts/SearchScript.groovy"
> is interpreted as the actual script (not its file name).
>
> Best regards,
> Pavol
>
>
>
> On 16.03.2016 15:39, Stephen Barker wrote:
>> Sure Thing! It's really basic. The password has been stripped out of
>> this configuration.
>>
>> <resource
>> xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
>>
>> xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
>>
>> xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
>>
>> xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
>> xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
>>
>> xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
>>           oid="fe1b0541-9b77-4019-9c76-384839cc09aa"
>>           version="15">
>>    <name>UIC IAM Sim</name>
>>    <metadata>
>> <modifyTimestamp>2016-03-16T08:51:09.824-05:00</modifyTimestamp>
>>       <modifierRef
>> xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
>>                    oid="00000000-0000-0000-0000-000000000002"
>>                    type="tns:UserType"/>
>>
>> <modifyChannel>http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</modifyChannel>
>>
>>    </metadata>
>>    <operationalState>
>> <lastAvailabilityStatus>up</lastAvailabilityStatus>
>>    </operationalState>
>>    <connectorRef oid="3bd53df6-3b55-4aa8-a163-7522424926ea"
>> type="c:ConnectorType"><!-- ICF
>> net.tirasa.connid.bundles.db.scriptedsql.ScriptedSQLConnector v2.2.3
>> --></connectorRef>
>>    <connectorConfiguration
>> xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
>>       <icfc:configurationProperties
>> xmlns:gen808="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/net.tirasa.connid.bundles.db.scriptedsql/net.tirasa.connid.bundles.db.scriptedsql.ScriptedSQLConnector">
>>
>> <gen808:searchScript>/opt/midpoint/config/scripted_connectors/uic_iam_scripts/SearchScript.groovy</gen808:searchScript>
>>
>>
>> <gen808:schemaScriptFileName>/opt/midpoint/config/scripted_connectors/uic_iam_scripts/SchemaScript.groovy</gen808:schemaScriptFileName>
>>
>>
>> <gen808:reloadScriptOnExecution>true</gen808:reloadScriptOnExecution>
>> <gen808:scriptingLanguage>GROOVY</gen808:scriptingLanguage>
>>          <gen808:user>simuser1</gen808:user>
>>          <gen808:password>
>>          </gen808:password>
>> <gen808:jdbcDriver>com.mysql.jdbc.Driver</gen808:jdbcDriver>
>>
>> <gen808:jdbcUrlTemplate>jdbc:mysql://localhost/uiciam</gen808:jdbcUrlTemplate>
>>
>> <gen808:enableEmptyString>true</gen808:enableEmptyString>
>>
>> <gen808:rethrowAllSQLExceptions>true</gen808:rethrowAllSQLExceptions>
>> <gen808:nativeTimestamps>true</gen808:nativeTimestamps>
>>          <gen808:allNative>true</gen808:allNative>
>>       </icfc:configurationProperties>
>>    </connectorConfiguration>
>>    <schema>
>>       <cachingMetadata>
>>
>> <retrievalTimestamp>2016-03-16T07:50:43.289-05:00</retrievalTimestamp>
>> <serialNumber>79d159e001005ada-ff062151864db51c</serialNumber>
>>       </cachingMetadata>
>>       <definition>
>>          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>
>> xmlns:ra="http://midpoint.evolveum.com/xml/ns/public/resource/annotation-3"
>>
>>
>> xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
>>
>>
>> xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
>>                      elementFormDefault="qualified"
>>
>> targetNamespace="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">
>>
>>             <xsd:import
>> namespace="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"/>
>>             <xsd:import
>> namespace="http://prism.evolveum.com/xml/ns/public/annotation-3"/>
>>             <xsd:import
>> namespace="http://midpoint.evolveum.com/xml/ns/public/resource/annotation-3"/>
>>             <xsd:complexType name="AccountObjectClass">
>>                <xsd:annotation>
>>                   <xsd:appinfo>
>>                      <ra:resourceObject/>
>> <ra:identifier>icfs:uid</ra:identifier>
>>
>> <ra:secondaryIdentifier>icfs:name</ra:secondaryIdentifier>
>>
>> <ra:displayNameAttribute>icfs:name</ra:displayNameAttribute>
>> <ra:namingAttribute>icfs:name</ra:namingAttribute>
>>
>> <ra:nativeObjectClass>__ACCOUNT__</ra:nativeObjectClass>
>>                      <ra:kind>account</ra:kind>
>>                      <ra:default>true</ra:default>
>>                   </xsd:appinfo>
>>                </xsd:annotation>
>>                <xsd:sequence>
>>                   <xsd:element minOccurs="0" name="netid"
>> type="xsd:string">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>> <a:displayOrder>120</a:displayOrder>
>>
>> <ra:frameworkAttributeName>netid</ra:frameworkAttributeName>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                   <xsd:element ref="icfs:name">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>>                            <a:displayName>ConnId Name</a:displayName>
>> <a:displayOrder>110</a:displayOrder>
>>
>> <ra:frameworkAttributeName>__NAME__</ra:frameworkAttributeName>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                   <xsd:element minOccurs="0" name="identity_id"
>> type="xsd:string">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>> <a:displayOrder>130</a:displayOrder>
>>
>> <ra:frameworkAttributeName>identity_id</ra:frameworkAttributeName>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                   <xsd:element minOccurs="0" name="uin"
>> type="xsd:string">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>> <a:displayOrder>140</a:displayOrder>
>>
>> <ra:frameworkAttributeName>uin</ra:frameworkAttributeName>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                   <xsd:element minOccurs="0" name="netid_id"
>> type="xsd:string">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>> <a:displayOrder>150</a:displayOrder>
>>
>> <ra:frameworkAttributeName>netid_id</ra:frameworkAttributeName>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                   <xsd:element minOccurs="0" ref="icfs:uid">
>>                      <xsd:annotation>
>>                         <xsd:appinfo>
>>                            <a:displayName>ConnId UID</a:displayName>
>> <a:displayOrder>100</a:displayOrder>
>>                            <a:access>read</a:access>
>>                         </xsd:appinfo>
>>                      </xsd:annotation>
>>                   </xsd:element>
>>                </xsd:sequence>
>>             </xsd:complexType>
>>          </xsd:schema>
>>       </definition>
>>    </schema>
>>    <capabilities>
>>       <cachingMetadata>
>>
>> <retrievalTimestamp>2016-03-16T07:50:43.293-05:00</retrievalTimestamp>
>> <serialNumber>b830b522bf88fde3-65dceef39aa140d</serialNumber>
>>       </cachingMetadata>
>>       <native
>> xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">
>>          <cap:addRemoveAttributeValues/>
>>          <cap:activation>
>>             <cap:status/>
>>             <cap:lockoutStatus/>
>>          </cap:activation>
>>          <cap:credentials>
>>             <cap:password>
>> <cap:returnedByDefault>false</cap:returnedByDefault>
>>             </cap:password>
>>          </cap:credentials>
>>          <cap:liveSync/>
>>          <cap:testConnection/>
>>          <cap:create/>
>>          <cap:read/>
>>          <cap:update/>
>>          <cap:delete/>
>>          <cap:script>
>>             <cap:host>
>>                <cap:type>connector</cap:type>
>>             </cap:host>
>>          </cap:script>
>>       </native>
>>    </capabilities>
>> </resource>
>>
>> Thanks,
>> Stephen Barker
>> Senior Software Engineer - AITS
>> University of Illinois
>> sbarker at uillinois.edu
>> 265-0942
>> --
>> "we tend to be masters of our own fate, the only thing that stops us
>> from doing really cool things is time." -- Monty Oum
>>
>> On 03/16/2016 09:36 AM, Ivan Noris wrote:
>>> Hi Stephen,
>>>
>>> could you please also share the resource XML? (Anonymized if needed).
>>> Thank you.
>>>
>>> Regards,
>>> Ivan
>>>
>>> On 03/16/2016 03:03 PM, Stephen Barker wrote:
>>>> Hi All,
>>>>
>>>> I could use some help with the scripted SQL Connector.
>>>>
>>>> I am using midpoint 3.3 and the scripted connector from
>>>> net.tirasa.connid.bundles.db.scriptedsql.ScriptedSQLConnector.
>>>>
>>>> I have created a very simple schema and search script of which I can
>>>> see the schema script is working well. When I go to "Accounts" though
>>>> in the List Resources menu I get the error:
>>>>
>>>> 2016-03-16 08:28:58,305 [MODEL] [http-bio-8080-exec-7] ERROR
>>>> (com.evolveum.midpo
>>>> int.model.impl.controller.ModelController): Couldn't search objects in
>>>> provision
>>>> ing, reason: Generic error in the connector:
>>>> org.identityconnectors.framework.co
>>>> mmon.exceptions.ConnectorException(Search script
>>>> error)->groovy.lang.MissingProp
>>>> ertyException(No such property: midpoint for class: Script1) (class
>>>> com.evolveum
>>>> .midpoint.util.exception.SystemException)
>>>>
>>>>
>>>> My search script is pretty simple basically just returning all results
>>>> from a table.
>>>>
>>>> I'll include the contents at the bottom of this email.
>>>>
>>>> What am I missing in getting this set up?
>>>>
>>>> -----
>>>> SEARCH SCRIPT
>>>> -----
>>>>
>>>> import groovy.sql.Sql;
>>>> import groovy.sql.DataSet;
>>>> import groovy.text.SimpleTemplateEngine;
>>>>
>>>> log.info("Entering " + action + " Script");
>>>>
>>>> def sql = new Sql(connection);
>>>> def result = []
>>>> def where = "";
>>>>
>>>> if (query != null){
>>>>
>>>> //To implement...
>>>>
>>>> }
>>>>
>>>> switch ( objectClass ) {
>>>>
>>>> case "__ACCOUNT__":
>>>>    sql.eachRow("SELECT * from identity",
>>>> {result.add([__ENABLE__:true,__UID__:it.id, __NAME__:it.uin,
>>>> uin:it.uin)} );
>>>>    break;
>>>>
>>>> case "__GROUP__":
>>>>    log.info("Search Group");
>>>>    break;
>>>>
>>>> default:
>>>>    result;
>>>> }
>>>>
>>>> return result;
>>>>
>>>
>> _______________________________________________
>> midPoint mailing list
>> midPoint at lists.evolveum.com
>> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>



More information about the midPoint mailing list