Ad Group synchronization error

Hi all

I have to run a synchronization involving AD Groups and AccProduct table. In details, once a given group is read from AD, I need to find a Product in the AccProduct Table with Ident_AccProduct equals to SamAccountName of the group.

This procedure is pretty simple and it works fine against hundreds of groups except when in the following case: the Group’s SamAccountName is something like xxxxxx$MISERVER$xxxx.

The query I implemented to get the AccProduct is as following:

 Dim AccProdObjectResult = SystemObject.Connection.QueryObject(SystemQuery _
   .From("AccProduct") _
   .Select("CustomProperty01","UID_AccProduct") _
   .Filter("Ident_AccProduct = '" &  cstr(AccProd) & "'" )
   ).Result

 

where AccProd is equal to xxxxxx$MISERVER$xxxx.

the exception message is " Error loading system objects of class AccProduct (all) (AccProduct_Master)."

I’m afraid this error is related to the $----$ chars into the SamAccountName

I've also tried something like 

 Dim AccProdObjectResult = SystemObject.Connection.QueryObject(SystemQuery _
   .From("AccProduct") _
   .Select("CustomProperty01","UID_AccProduct") _
   .Filter("Ident_AccProduct = '" & cstr(AccProd) & "'" )
   ).Result
 

and like 

  Dim AccProdObjectResult = SystemObject.Connection.QueryObject( SystemQuery _     .From("AccProduct") _     .Select("CustomProperty01","UID_AccProduct") _     .Filter(String.Format("Ident_AccProduct = '{0}'",cstr(AccProd) ))     ).Result

 

but nothing changes.

Please can someone advices me about how to solve this issue?