static void ObtenerGruposDeUsuario(Args _args) { System.DirectoryServices.DirectorySearcher DirectorySearcher, ds; System.DirectoryServices.SearchScope SearchScope; System.DirectoryServices.DirectoryEntry DirectoryEntry,obUser; System.DirectoryServices.SearchResultCollection SearchResultCollection, resCol; System.DirectoryServices.SearchResult SearchResult, sr; System.DirectoryServices.PropertyCollection PropertyCollection, pc; System.DirectoryServices.PropertyValueCollection PropertyValueCollection, pvc; str networkDomain="DC=dominio,DC=com"; str prefix = "LDAP://"; int totalCount, j, y; int counter,userCount,ccn; str mysamaccountname; str myusername, groupsList, st, userName; Dialog dialog = new dialog("Introduce nombre del usuario"); DialogField field; ; field = dialog.addFieldValue(typeid("name"),"Pepe Diaz","AD User"); if(dialog.run()) { userName = field.value(); DirectoryEntry = new System.DirectoryServices.DirectoryEntry(prefix + networkDomain); SearchScope =CLRInterop::parseClrEnum('System.DirectoryServices.SearchScope', 'Subtree'); DirectorySearcher = new System.DirectoryServices.DirectorySearcher(DirectoryEntry); DirectorySearcher.set_SearchScope(searchScope); DirectorySearcher.set_Filter(strFmt('(&(objectClass=user)(name=%1))',userName)); SearchResultCollection = DirectorySearcher.FindAll(); totalCount = SearchResultCollection.get_Count(); for (counter=0; counter < totalcount; counter++) { SearchResult = SearchResultCollection.get_Item(counter); DirectoryEntry = SearchResult.GetDirectoryEntry(); if (DirectoryEntry) { PropertyCollection = DirectoryEntry.get_Properties(); if (PropertyCollection) { PropertyValueCollection = PropertyCollection.get_Item('samaccountname'); mysamaccountname=PropertyValueCollection.get_Value(); PropertyValueCollection = PropertyCollection.get_Item('name'); myusername=PropertyValueCollection.get_Value(); PropertyValueCollection = PropertyCollection.get_Item('memberOf'); ccn = PropertyValueCollection.get_Count(); for (j=0; j