none
Export Only MA is not running PutExportEntries RRS feed

  • Question

  • Hi, 

    I am new to FIM 2010, my team is developing a data synchronization product for 4 types of Systems (PeopleSoft, AD, SAP and Lenel). In these four systems, Lenel is the only one which just have to take data from other three system, and it's entries will only be added, updated or deleted according to SAP, PS, or AD profiles. So essentially it's an export only type management agent. Lenel system doesn't have any webservices to use as a startup point for management agent creation, so after a thorough analysis we have decided to use Extensible Connectivity 2.0. And this system is MS-SQL based. 
    By using MSDN guide (Create the SQL_ECMA2 DLL) I have developed my project to create Export only MA, my project doesn't implement "IMAExtensible2CallImport" interface. 

    But now after creating and running it's export profile, it doesn't do anything, it shows success status, but it doesn't read any data from Metaverse to bring in it's connector space and then to external DB System (Lenel CSEntries List is empty). When I checked my Users Set from portal I can see my Lenel-Outbound Synchronization rule listed there but it's status is "Not Applied" to every user which should have this Synchronization Rule in it's provision.

    According to the above mentioned guide Step 8 (Create the MVExtension DLL) I have to create another project "MVExtension.dll" to set MVObject to CSEntry but as I do this, it gives error too (Error: 'extension-dll-exception', stack trace: Microsoft.MetadirectoryServices.NoSuchAttributeInObjectTypeException: Attribute "employeeID" is not usable with the object type in question.) but it brings data to csentries list somehow. Also it causes errors for rest of the MAs (PS, FIMMA, ADMA, SAPMA) and doesn't synchronize all the systems with FIMMA. FIMMA gets errors on Import/Export/Full Synchronization steps too.  
    Please help me out here, I have tried to do a thorough search but no solution found, I am posting here in hope to get some better lead. 

    Is there any way to load CSEntries List objects from Metaverse objects in ExportConnection code or any-other guide which shows how can I run an Export Only MA ? 

    Following is my code snippet:

    using System;
    using System.IO;
    using System.Xml;
    using System.Text;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Collections.Specialized;
    using Microsoft.MetadirectoryServices;
    using System.Management;
    using System.Security.Principal;
    using System.Diagnostics;
    using System.Security;
    using System.Linq;
    using System.Threading.Tasks;
    
    namespace LNL_ConnectorExtension
    {
        using System;
        using System.IO;
        using System.Xml;
        using System.Text;
        using System.Collections.Specialized;
        using System.Collections.Generic;
        using System.Collections.ObjectModel;
        using Microsoft.MetadirectoryServices;
        using System.Data.SqlClient;
        using System.Data;
        using System.Management;
        using System.Security.Principal;
        using System.Diagnostics;
        using System.Security;
        using System.IO;
        using System.Reflection;
    
        namespace FimSync_Ezma
        {
            public class EzmaExtension :
            IMAExtensible2CallExport,
                //IMAExtensible2CallImport,
                //IMAExtensible2FileImport,
                //IMAExtensible2FileExport,
                //IMAExtensible2GetHierarchy,
            IMAExtensible2GetSchema,
            IMAExtensible2GetCapabilities,
            IMAExtensible2GetParameters
            //IMAExtensible2GetPartitions
            {
                private int m_importDefaultPageSize = 12;
                private int m_importMaxPageSize = 50;
                private int m_exportDefaultPageSize = 10;
                private int m_exportMaxPageSize = 20;
                public string myConnection;
                public string myDB;
                public string myServer;
                public string myTable;
    
                public string dbUsername;
                public string dbpwd;
               // SecureString dbpwd = new SecureString();
    
                SqlConnection conn;
                SqlCommand cmd;
                SqlDataAdapter adapter;
                DataSet da;
                public string myFirst;
                public string myLast;
                public string myEmail;
                public string myEmpID;
                public string myFull;
                public string myAccount;
    
                private string m_exePath = string.Empty;
                /*######################## LNL ENTRY REQ FIELDS ##############################*/
                public string entryFirstName;
                public string entryMidName;
                public string entryLastName; // it cannot be null, must set this.
                public string entrySSNO;
                // end of EMP table columns
    
                public int entryBadgeType; // employee or student, 1 or 4, Table name BADGETYP
                public int entryBadgeStatus; //Active (1) or inactive (0) table name BADGSTAT
                public int entryTwoManType = 0;
                public int entryDefaultFloor = 0;
                // end of BADGE table columns
    
                public string entryCampusID;
    
                // Start of UDFEMP table columns
                public string entryAddress;
                public string entryCity;
                public string entryState;
                public string entryPhone;
                public string entryBdate;
                public int entryTitle = 0;
                public string entryCNIC; // dashed format
    
                public string entryEmail;
                public int entryDivision = 0;
                public int entryLocation = 0;
    
                public string gradYearStr;
                public int entryGradYear;
                public int entrySchoolName = 0;
                public string entryFLDTEXT867; // campus id stored as dashed format 2015-02-0128
                public string entryFLDTEXT869;  // employee id stored as E0395
    
                public int entryDept; // set ID w.r.t. "NAME" attribute in table DEPT , to sych this, query rule table first
                public string departmentStr;
    
                public int entryProgram; // set ID w.r.t. "NAME" attribute in table PROGRAMME, NULL for staff (RULE TABLE QUERY)
                public string programStr;
    
                public int entryHostel; // set ID w.r.t. "NAME" attribute in table HOSTELNAME, NULL for staff (RULE TABLE QUERY)
                public string hostelStr;
    
                public int entryDesignation; // set ID w.r.t. "NAME" attribute in table DESIGNATION, NULL for staff (RULE TABLE QUERY)
                public string designationStr;
    
                public int entryAlumniProg; // set ID w.r.t. "NAME" attribute in table ALUMINIPROGRAM, NULL for staff (RULE TABLE QUERY)
                public string alumniProgStr;
    
                public string entryRoomNumber;
    
                public string entryEMPID;
    
                // end of UDFEMP table columns
    
                public byte[] entryImage;
                // end of MMOBJ table columns
    
                public string entryNowDate = DateTime.Now.ToString(); // for activate date
                public string entryEndDate = DateTime.Now.AddYears(4).ToString(); // for deactivate date
    
                public string noDashFormat;
                public char[] charsToTrim = { '0', '*', ' ', '\'' };
    
                //
                // Constructor
                //
                public EzmaExtension()
                {
                    //
                    // TODO: Add constructor logic here
                    //
                }
    
                public MACapabilities Capabilities
                {
                    get
                    {
                        MACapabilities myCapabilities = new MACapabilities();
    
                        myCapabilities.ConcurrentOperation = true;
                        myCapabilities.ObjectRename = false;
                        myCapabilities.DeleteAddAsReplace = true;
                        myCapabilities.DeltaImport = false;
                        myCapabilities.DistinguishedNameStyle = MADistinguishedNameStyle.None;
                        myCapabilities.ExportType = MAExportType.AttributeUpdate;
                        myCapabilities.NoReferenceValuesInFirstExport = false;
                        myCapabilities.Normalizations = MANormalizations.None;
    
                        return myCapabilities;
                    }
                }
    
                public IList<ConfigParameterDefinition> GetConfigParameters(KeyedCollection<string, ConfigParameter> configParameters,
                                                                ConfigParameterPage page)
                {
                    List<ConfigParameterDefinition> configParametersDefinitions = new List<ConfigParameterDefinition>();
    
                    switch (page)
                    {
                        case ConfigParameterPage.Connectivity:
    
                            configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter("Server", ""));
                            configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter("Database", ""));
                            configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter("Table", ""));
                            configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter("Database Username", ""));
                            configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter("Database Password", ""));
                            
                            break;
    
    
                        case ConfigParameterPage.Global:
    
    
                            break;
    
                        case ConfigParameterPage.Partition:
                            break;
    
                        case ConfigParameterPage.RunStep:
    
                            break;
                    }
    
                    return configParametersDefinitions;
                }
    
                public ParameterValidationResult ValidateConfigParameters(KeyedCollection<string, ConfigParameter> configParameters,
                                                                       ConfigParameterPage page)
                {
    
    
                    ParameterValidationResult myResults = new ParameterValidationResult();
    
                    return myResults;
    
                }
    
                public Schema GetSchema(KeyedCollection<string, ConfigParameter> configParameters)
                {
                    System.Diagnostics.Debugger.Launch();
    
                    Microsoft.MetadirectoryServices.SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create("Person", false);
    
                    myServer = configParameters["Server"].Value;
                    myDB = configParameters["Database"].Value;
                    myTable = configParameters["Table"].Value;
                    dbUsername = configParameters["Database Username"].Value;
                    dbpwd = configParameters["Database Password"].Value;
    
                    LogWrite("Before SQL Schema function call");
                    DataSet myData = this.SQLSchema(myServer, myDB, myTable, dbUsername, dbpwd);
                    LogWrite("After SQL Schema function call to ensure we have a connection.");
    
                    string[] SQLSchema = new string[myData.Tables["Columns"].Rows.Count];
    
    
                    for (int i = 0; i <= myData.Tables["Columns"].Rows.Count - 1; i++)
                    {
    
                        SQLSchema[i] = myData.Tables["Columns"].Rows[i].ItemArray.GetValue(0).ToString().Trim();
                        string myattrib = SQLSchema[i];
                        LogWrite("For Loop myattrib:  "+i+"   "+myattrib);
    
                        if (myattrib == "EMPID")
                        {
                            personType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute(myattrib, AttributeType.String));
                        }
    
                        else
                        {
                            personType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(myattrib, AttributeType.String));
                        }
    
                    }
    
                    Schema schema = Schema.Create();
                    schema.Types.Add(personType);
    
                    return schema;
                }
    
                public DataSet SQLSchema(string server, string database, string table, string dbUsername, string password)
                {
                    System.Diagnostics.Debugger.Launch();
                    try
                    {
    
                        myConnection = ("Server = '" + server + "';Initial Catalog='" + database + "';User Id=" + dbUsername + ";Password=" + password + ";");
                        LogWrite("SQLSchema Function: " + myConnection);
                        conn = new SqlConnection(myConnection);
                        LogWrite("SQL Connection string set in object." );
                        cmd = new SqlCommand();
                        
                        cmd.CommandType = CommandType.Text;
                        string cmdText = "Select COLUMN_NAME from Information_Schema.Columns where TABLE_Name = '" + table + "'";
                        cmd.CommandText = cmdText;
                        cmd.Connection = conn;
                        
                        adapter = new SqlDataAdapter(cmd);
                        da = new DataSet();
                       
                        LogWrite("before fill func: ");
                        adapter.Fill(da, "Columns");
                        LogWrite("after fill func: "+adapter.ToString());
                        
                        return da;
                    }
                    catch (SqlException ex) { 
                         switch (ex.Number) 
                           { 
                             case 4060: // Invalid Database 
                                  LogWrite("Invalid Database Exception.");
                                  break;    
                             case 18456: // Login Failed 
                                  LogWrite("Login Failed Exception.");
                                  break;
                             default:
                                 LogWrite("Connection string Exception.");
                                 LogWrite(ex.Message + "  \n   " + ex.ErrorCode.ToString() + "  \n   " + ex.StackTrace);
                                 break;
                           }
                         return (new DataSet());
                    }
    
                }
    
                public void OpenExportConnection(KeyedCollection<string, ConfigParameter> configParameters,
                                    Schema types,
                                    OpenExportConnectionRunStep exportRunStep)
                {
                    System.Diagnostics.Debugger.Launch();
                    myServer = configParameters["Server"].Value;
                    myDB = configParameters["Database"].Value;
                    myTable = configParameters["Table"].Value;
                    dbUsername = configParameters["Database Username"].Value;
                    dbpwd = configParameters["Database Password"].Value;
    
                    myConnection = ("Server = '" + myServer + "';Initial Catalog='" + myDB + "';UserID='" + dbUsername + "';Password='" + dbpwd + "';");
                    LogWrite("ExportConnection Function: " + myConnection);
                    conn = new SqlConnection(myConnection);
                    cmd = new SqlCommand();
                    cmd.CommandType = CommandType.Text;
                    conn.Open();
    
                }
    
                public PutExportEntriesResults PutExportEntries(IList<CSEntryChange> csentries)
                {
                    int i = 0;
                    foreach (CSEntryChange csentryChange in csentries)
                    {
                        myEmpID = csentries[i].DN.ToString();
    
                        if (csentryChange.ObjectType == "Person")
                        {
                            #region Add
    
                            if (csentryChange.ObjectModificationType == ObjectModificationType.Add)
                            {
                                #region a
    
                                foreach (string attrib in csentryChange.ChangedAttributeNames)
                                {
                                    switch (attrib)
                                    {
                                        case "firstName":
                                            // myFirst = csentryChange.ChangedAttributeNames[0].ToString();
                                            myFirst = csentryChange.AttributeChanges["firstName"].ValueChanges[0].Value.ToString();
                                            entryFirstName = csentryChange.AttributeChanges["firstName"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "lastName":
                                            myLast = csentryChange.AttributeChanges["lastName"].ValueChanges[0].Value.ToString();
                                            if (myLast != null)
                                                entryLastName = csentryChange.AttributeChanges["lastName"].ValueChanges[0].Value.ToString();
                                            else
                                                entryLastName = myFirst;
                                            break;
    
                                        case "middleName":
                                            entryMidName = csentryChange.AttributeChanges["middleName"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "email":
                                            myEmail = csentryChange.AttributeChanges["email"].ValueChanges[0].Value.ToString();
                                            entryEmail = csentryChange.AttributeChanges["email"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "accountName":
                                            entryCampusID = csentryChange.AttributeChanges["accountName"].ValueChanges[0].Value.ToString();
                                            entryEMPID = entryCampusID;
                                            break;
    
                                        case "X_CAMPUS_ID":
                                            entryFLDTEXT867 = csentryChange.AttributeChanges["X_CAMPUS_ID"].ValueChanges[0].Value.ToString();
                                            noDashFormat = replaceHypenCharacterInRollNumber(entryFLDTEXT867);
                                            int currentYear = DateTime.Now.Year;
    
                                            if (Convert.ToInt32(noDashFormat.Substring(0, 3)) + 4 > currentYear)
                                            {
                                                entrySSNO = "11" + noDashFormat;
                                                entryBadgeType = 4;
                                            }
                                            else
                                            {
                                                entrySSNO = "15" + noDashFormat;
                                                entryBadgeType = 5;
                                            }
                                            break;
    
                                        case "employeeID":
                                            entryFLDTEXT869 = csentryChange.AttributeChanges["employeeID"].ValueChanges[0].Value.ToString();
                                            if (entryFLDTEXT869 != null && entryFLDTEXT869.StartsWith("E"))
                                            {
                                                entrySSNO = "21" + entryFLDTEXT869.Substring(1).PadLeft(10, '0');
                                                entryBadgeType = 1;
                                            }
    
                                            break;
    
                                        case "country":
                                            entryState = csentryChange.AttributeChanges["country"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "address":
                                            entryAddress = csentryChange.AttributeChanges["address"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "city":
                                            entryCity = csentryChange.AttributeChanges["city"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "mobilePhone":
                                            entryPhone = csentryChange.AttributeChanges["mobilePhone"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "department":
                                            departmentStr = csentryChange.AttributeChanges["department"].ValueChanges[0].Value.ToString();
                                            // entryDesignation figure out rule table
                                            break;
    
                                        //case "division":
                                        //    entryDivision = Convert.ToInt32(csentryChange.AttributeChanges["division"].ValueChanges[0].Value);
                                        //    break;
    
                                        case "position":
                                            designationStr = csentryChange.AttributeChanges["position"].ValueChanges[0].Value.ToString();
                                            entryDesignation = getDesignationId(designationStr);
                                            // entryDesignation figure out rule table
                                            break;
    
                                        case "cnic":
                                            entryCNIC = csentryChange.AttributeChanges["cnic"].ValueChanges[0].Value.ToString();
                                            break;
    
                                        case "photo":
                                            // entryImage = csentryChange.AttributeChanges["photo"].ValueChanges[0].Value.ToString();
                                            // findout how to assign blob to this
                                            break;
    
                                        case "X_PS_PROGRAM":
                                            programStr = csentryChange.AttributeChanges["X_PS_PROGRAM"].ValueChanges[0].Value.ToString();
                                            // add query to rule table and map that to entryProgram
                                            break;
    
                                    }
    
    
                                }
                                #endregion
    
                                int empID = getLastIDofTable("dbo.EMP") + 1;
                                string empCmdText = "Insert into dbo.EMP (ID, FIRSTNAME, LASTNAME, SSNO, MIDNAME) VALUES ('" + empID + "','" + entryFirstName + "','" + entryLastName + "','" + entrySSNO + "','" + entryMidName + "') SELECT SCOPE_IDENTITY()";
                                cmd.CommandText = empCmdText;
                                cmd.Connection = conn;
                                //cmd.ExecuteNonQuery();
                                int EMPID = (int)cmd.ExecuteScalar();
    
                                int udfEMPLID = getLastIDofTable("dbo.UDFEMP");
                                string udfCmdText = "Insert into dbo.UDFEMP (ID, ADDR1, CITY, STATE, PHONE, BDATE, TITLE, DEPT, DIVISION, EMAIL, LOCATION, PROGRAMME, CNIC, HOSTELNAME, SCHOOLNAME, DESIGNATION, ROOMNO, ALUMINIPROGRAM, FLDTEXT867, FLDTEXT869) VALUES ('" + empID + "','" + entryAddress + "','" + entryCity + "','" + entryState + "','" + entryPhone + "','" + entryBdate + "','" + entryTitle + "','" + entryDept + "','" + entryDivision + "','" + entryEmail + "','" + entryLocation + "','" + entryProgram + "','" + entryCNIC + "','" + entryHostel + "','" + entrySchoolName + "','" + entryDesignation + "','" + entryRoomNumber + "','" + entryAlumniProg + "','" + entryFLDTEXT867 + "','" + entryFLDTEXT869 + "') SELECT SCOPE_IDENTITY()";
                                cmd.CommandText = udfCmdText;
                                cmd.Connection = conn;
                                //cmd.ExecuteNonQuery();
                                int UDFEMPID = (int)cmd.ExecuteScalar();
    
                                string badgeCmdText = "Insert into dbo.BADGE (ISSUECODE, EMPID, STATUS, TYPE, ACTIVATE, DEACTIVATE, BADGEKEY) VALUES (0," + empID + ",1," + entryBadgeType + "','" + entryNowDate + "','" + entryEndDate + "','" + empID + "') ";
                                cmd.CommandText = badgeCmdText;
                                cmd.Connection = conn;
                                cmd.ExecuteNonQuery();
    
                                string mimTblCmdText = "INSERT INTO dbo.LNL_MIM_ATTRIBUTE (EMPID,LASTNAME,FIRSTNAME,SSNO,BADGETYPE,BADGE_STATUS, ISSUECODE,BADGEKEY,CAMPUS_ID,EMAIL,FLDTEXT867,FLDTEXT869) VALUES ('" + entryEMPID + "','" + entryLastName + "','" + entryFirstName + "','" + entrySSNO + "','" + entryBadgeType + ",1,0," + "','" + entryEMPID + "','" + entryCampusID + "','" + entryEmail + "','" + entryFLDTEXT867 + "','" + entryFLDTEXT869 + "')";
                                cmd.CommandText = mimTblCmdText;
                                cmd.Connection = conn;
                                cmd.ExecuteNonQuery();
    
                            }
    
                            #endregion
    
                            #region implementLater
                            /*     #region Delete
                            if (csentryChange.ObjectModificationType == ObjectModificationType.Delete)
                            {
    
                                myEmpID = csentries[i].DN.ToString();
                                string cmdText = "Delete from " + myTable + "Where EmployeeID = '" + myEmpID + "'";
                                cmd.CommandText = cmdText;
                                cmd.Connection = conn;
                                cmd.ExecuteNonQuery();
    
    
                            }
                            #endregion
    
                            #region Update
                            if (csentryChange.ObjectModificationType == ObjectModificationType.Update)
                            {
    
                                foreach (string attribName in csentryChange.ChangedAttributeNames)
                                {
    
    
                                    if (csentryChange.AttributeChanges[attribName].ModificationType == AttributeModificationType.Add)
                                    {
                                        myEmpID = csentryChange.AnchorAttributes[0].Value.ToString();
                                        string attribValue = csentryChange.AttributeChanges[attribName].ValueChanges[0].Value.ToString();
                                        string cmdText = "Update" + myTable + "SET" + attribName + " = '" + attribValue + "' Where EmployeeID = '" + myEmpID + "'";
                                        cmd.CommandText = cmdText;
                                        cmd.Connection = conn;
                                        cmd.ExecuteNonQuery();
                                    }
                                    else if (csentryChange.AttributeChanges[attribName].ModificationType == AttributeModificationType.Delete)
                                    {
    
                                        myEmpID = csentryChange.AnchorAttributes[0].Value.ToString();
                                        string cmdText = "Update " + myTable + " SET " + attribName + " = 'NULL' Where EmployeeID = '" + myEmpID + "'";
                                        cmd.CommandText = cmdText;
                                        cmd.Connection = conn;
                                        cmd.ExecuteNonQuery();
                                    }
                                    else if (csentryChange.AttributeChanges[attribName].ModificationType == AttributeModificationType.Replace)
                                    {
                                        myEmpID = csentryChange.AnchorAttributes[0].Value.ToString();
                                        string attribValue = csentryChange.AttributeChanges[attribName].ValueChanges[0].Value.ToString();
                                        string cmdText = "Update " + myTable + " SET " + attribName + " = '" + attribValue + "' Where EmployeeID = '" + myEmpID + "'";
                                        cmd.CommandText = cmdText;
                                        cmd.Connection = conn;
                                        cmd.ExecuteNonQuery();
                                    }
                                    else if (csentryChange.AttributeChanges[attribName].ModificationType == AttributeModificationType.Update)
                                    {
                                        myEmpID = csentryChange.AnchorAttributes[0].Value.ToString();
                                        string attribValue = csentryChange.AttributeChanges[attribName].ValueChanges[0].Value.ToString();
                                        string cmdText = "Update " + myTable + " SET " + attribName + " = '" + attribValue + "' Where EmployeeID = '" + myEmpID + "'";
                                        cmd.CommandText = cmdText;
                                        cmd.Connection = conn;
                                        cmd.ExecuteNonQuery();
                                    }
    
    
    
    
                                }
    
    
    
    
                            }
    
                            #endregion
                            */
                            #endregion
    
                        }
    
                        i++;
    
                    }
    
    
    
    
                    PutExportEntriesResults exportEntriesResults = new PutExportEntriesResults();
    
                    return exportEntriesResults;
                }
    
    
                public void CloseExportConnection(CloseExportConnectionRunStep exportRunStep)
                {
                    conn.Close();
    
    
                }
    
                public int ExportDefaultPageSize
                {
                    get
                    {
                        return m_exportDefaultPageSize;
                    }
                    set
                    {
                        m_exportDefaultPageSize = value;
                    }
                }
    
                public int ExportMaxPageSize
                {
                    get
                    {
                        return m_exportMaxPageSize;
                    }
                    set
                    {
                        m_exportMaxPageSize = value;
                    }
                }
    
                public string replaceHypenCharacterInRollNumber(string campusId)
                {
                    StringBuilder sb = new StringBuilder(campusId);
                    sb.Replace("-", "");
                    campusId = sb.ToString();
                    return campusId;
                }
    
                
    
                public int getLastIDofTable(string tablename)
                {
                    string connectionStr = "Server = '" + myServer + "';Initial Catalog='" + myDB + "';Integrated Security=True;User ID="+dbUsername+";Password="+dbpwd+";";
                    SqlConnection connection = new SqlConnection(connectionStr);
                    SqlCommand command = new SqlCommand("SELECT TOP(1) ID FROM " + tablename + " ORDER BY 1 DESC", connection);
    
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
    
                    //won't need a while, since it will only retrieve one row
                    reader.Read();
    
                    //here is your data
                    int data = Convert.ToInt32(reader["ID"].ToString());
    
                    reader.Close();
                    connection.Close();
                    return data;
                }
    
                public int getDesignationId(string position)
                {
                    string connectionStr = "Server = '" + myServer + "';Initial Catalog='" + myDB + "';Integrated Security=True;User ID=" + dbUsername + ";Password=" + dbpwd + ";";
                    SqlConnection connection = new SqlConnection(connectionStr);
                    SqlCommand command = new SqlCommand("SELECT ID FROM dbo.DESIGNATION WHERE NAME = '" + position + "' ORDER BY 1 DESC", connection);
    
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
    
                    //won't need a while, since it will only retrieve one row
                    reader.Read();
    
                    //here is your data
                    int data = Convert.ToInt32(reader["ID"].ToString());
    
                    reader.Close();
                    connection.Close();
                    return data;
                }
    
    
                
    
    
    
            };
    
        }
    }
    

    Regards. 

    Monday, January 15, 2018 3:11 PM

All replies

  • Your problem isn't with your ECMA but with your sync rule and/or MV extension. The ExportEntries method isn't going to be called if there is nothing to export, which based on your description is the case.

    > Microsoft.MetadirectoryServices.NoSuchAttributeInObjectTypeException: Attribute "employeeID" is not usable with the object type in question

    This error implies that you are referencing an attribute called employeeID which doesn't exist either in the Metaverse or your connector space schema. If you solve that, that will solve this problem. Once your sync rule is applied and you can run a synchronization on your test object with no errors, you should get pending exports.


    Thanks,
    Brian

    Consulting | Blog | AD Book

    Monday, January 15, 2018 8:06 PM
    Moderator
  • Hi Brian, 

    Thank you for responding on this. I am unable to verify my ECMA2-connector space schema, I can only see the Attributes from MA-Properties, is there any other way to browse connector space schema ? (This may sound stupid question but I am naive in this regard). 

    Also, when I enabled MVExtension.dll and do Full Import -> Full Synch on FIMMA, it applies my synchronization rule to all Users Set, I can see that from Portal User's Profile window but on frontend of Synchronization Service Manager it gives above mentioned error too. without this "MVExtension.dll" my synchronization rule doesn't apply to users set.

    Because there are other systems' management agents conflicts/issues with this MVExtension.dll, I need some other solution to make it work without MVExtension.dll

    I have tried Rule Extensions on AttributeFlow but it didn't work at all. After some more research, I think there is only one way left to do this, where I have to create SOAP based MA. but I am not sure yet if I am in the right direction. 

    Any help in this regard will be appreciated. 

    Thanks.

    Tuesday, January 16, 2018 4:29 AM
  • The schema is something your ECMA code provides. It's possible that error is referring to another MA but I don't have enough details to confirm that.

    I think you need to break your problems into manageable chunks. Until you get your provisioning code (MVExtension) and/or sync rules working, it's somewhat irrelevant whether your MA works or not. Creating another web services (SOAP) MA will not help you. You might want to just substitute a flat file MA, for example, with the same schema and use it to get your code/sync rules working and then add the ECMA in later.


    Thanks,
    Brian

    Consulting | Blog | AD Book

    • Marked as answer by mysasma Tuesday, January 16, 2018 1:15 PM
    • Unmarked as answer by mysasma Tuesday, January 16, 2018 1:15 PM
    Tuesday, January 16, 2018 5:36 AM
    Moderator
  • Hi,

    In addition to the responses you already received, the code is susceptible to SQL Injection Attacks.

    If a user can edit one of the fields flowed to your agent, they can perform an SQL Injection attack. 

    Please see https://en.wikipedia.org/wiki/SQL_injection

    Br,

    Leo


    Did my post help? Please use "Vote As Helpful", "Mark as answer" or "Propose as answer". Thank you!

    Tuesday, January 16, 2018 9:44 AM
  • Thank you Brian, I have tried to test it with flat file ma something is wrong, synchronization rule applied to Users set but export didn't work. Anyway due to short timeline I am switching my approach and start using webservice based MA. Although system doesn't have any exposed webservices so I have to first create one but I hope this will work. 

    Thankyou all for your responses. If later on I will be able to solve this problem or find out what was causing this issue I will update here. 

    Tuesday, January 16, 2018 1:15 PM