ECMA extension error during Import RRS feed

  • Question

  • Hi,

    I am writing my own Extension project to provision users to Lync.

    At the moment, I'm only testing out the import functionality. However, everytime I do a full import, I get an invalid-attribute-value on DistinguishedName. The value being passed is a proper DN ("CN=Joe Bloggs,OU=LyncUsers,DC=testlab,DC=com"), and I even tried passing a dummy string "foo", but I always get the same error.

    In the Import code, I set the DN correctly as far as I can tell:

    public GetImportEntriesResults GetImportEntries(GetImportEntriesRunStep importRunStep)
                GetImportEntriesResults importReturnInfo;
                List<CSEntryChange> csentries = new List<CSEntryChange>();
                InitialSessionState initial = InitialSessionState.CreateDefault();
                initial.ImportPSModule(new string[] { "C:\\Program Files\\Common Files\\Microsoft Lync Server 2010\\Modules\\Lync\\Lync.psd1" });
                Runspace runspace = RunspaceFactory.CreateRunspace(initial);
                PowerShell ps = PowerShell.Create();
                ps.Runspace = runspace;
                // get-csaduser -filter {Enabled =eq $True -and SipAddress -ne $Null}
                ScriptBlock filter = ScriptBlock.Create("$_.Enabled -eq $True -and $_.SipAddress -ne $Null");
                ps.AddParameter("FilterScript", filter);
                foreach (PSObject result in ps.Invoke())
                    string myDN = string.Format("CN={0},OU=LyncUsers,DC=testlab,DC=com",result.Members["displayName"].Value);
                    CSEntryChange csentry1 = CSEntryChange.Create();
                    csentry1.ObjectModificationType = ObjectModificationType.Add;
                    csentry1.ObjectType = "user";
                    csentry1.DN = myDN;
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("firstName", result.Members["firstName"].Value));
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("LastName", result.Members["lastName"].Value));
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("EmployeeID", result.Members["employeeID"].Value);
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("accountName", result.Members["samAccountName"].Value));
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("SipAddress", result.Members["SipAddress"].Value));
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("ID", "testlab\\" + result.Members["samAccountName"].Value));
                    csentry1.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("Domain", "testlab"));
                importReturnInfo = new GetImportEntriesResults();
                importReturnInfo.MoreToImport = false;
                importReturnInfo.CSEntries = csentries;
                return importReturnInfo;

    Any idea why I'm getting this error repeatedly?

    Thanks in advance

    Wednesday, June 12, 2013 9:28 PM


  • Have you checked the schema definition for user?

    • Marked as answer by kmittal82 Thursday, June 13, 2013 4:07 PM
    Thursday, June 13, 2013 1:49 PM

All replies

  • Have you tried running it in debug mode and putting a breakpoint where the the DN is getting generated? If for instance the "displayName" field is missing or not coming through for a user from the PowerShell script for whatever reason you will get an improperly formatted DN.

    Also, what version of FIM Sync Service are you using? There are a variety of versions of ECMA 2 out there with different releases

    Wednesday, June 12, 2013 10:59 PM
  • Yes, I have put a breakpoint and verified the DN value is correctly formatted. Also, when FIM report the error, the string is shown which looks correct too:

    CN=Joe Bloggs,OU=LyncUsers,DC=testlab,DC=com

    I'm using the displayName field to generate the CN as you can see. Should I just add that as an attribute as well for the csentry object? 

    Also, just to check, I even tried hardcoding the DN, once with "CN=Joe Bloggs,OU=LyncUsers,DC=testlab,DC=com" and once with simply "foo", and in both cases I saw the same error.

    I'm using the latest ECMA build, ECMA 2.2

    • Edited by kmittal82 Wednesday, June 12, 2013 11:08 PM
    Wednesday, June 12, 2013 11:05 PM
  • Have you checked the schema definition for user?

    • Marked as answer by kmittal82 Thursday, June 13, 2013 4:07 PM
    Thursday, June 13, 2013 1:49 PM
  • That was it, my schema didn't match up with the entries I was adding in the CSObject, all down to a typo!

    Thanks for your tip :)

    Thursday, June 13, 2013 4:07 PM