Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting Script to VFP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01243994
Message ID:
01243997
Vues:
19
>Hi Gang,
>
>I've finally got my scripts working the way I want them to, but now I need to get all the code over into VFP (instead of script) so I can handle some additional processes, etc.
>
>The code I am using in script (which works properly and does exactly what I want it to do is:
>
>Const ADS_SCOPE_SUBTREE = 2
>Set objConnection = CreateObject("ADODB.Connection")
>Set objCommand =   CreateObject("ADODB.Command")
>objConnection.Provider = "ADsDSOObject"
>objConnection.Open "Active Directory Provider"
>Set objCommand.ActiveConnection = objConnection
>objCommand.Properties("Page Size") = 1000
>objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
>objCommand.CommandText = _
>    "SELECT distinguishedName,Name,displayname FROM 'LDAP://dc=bogus,dc=local' WHERE objectCategory='user' " & _
>Set objRecordSet = objCommand.Execute
>objRecordSet.MoveFirst
>Do Until objRecordSet.EOF
>    Wscript.Echo objRecordSet.Fields("distinguishedName").Value
>    Wscript.Echo objRecordSet.Fields("Name").Value
>    Wscript.Echo objRecordSet.Fields("displayName").Value
>    objRecordSet.MoveNext
>Loop
>
>
>Does anyone have enough familiarity with script and VFP to tell me what syntax changes have to be made to work in VFP? Obviously I'll drop the "Set" command, etc. Other than that, I'm having a tough time. :-)
>
>Thanks,
#DEFINE ADS_SCOPE_SUBTREE  2

local objConnection, objCommand, objRecordSet

objConnection = CreateObject("ADODB.Connection")
objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open("Active Directory Provider")
objCommand.ActiveConnection = objConnection
 objCommand.Properties("Page Size") = 1000 && this I'm not 100% sure
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE  && Same here
objCommand.CommandText = ;
    "SELECT distinguishedName,Name,displayname FROM 'LDAP://dc=bogus,dc=local' WHERE objectCategory='user' " 

objRecordSet = objCommand.Execute()

objRecordSet.MoveFirst()

Do while objRecordSet.EOF
    ? objRecordSet.Fields("distinguishedName").Value
    ? objRecordSet.Fields("Name").Value
    ? objRecordSet.Fields("displayName").Value
    objRecordSet.MoveNext()
enddo
store null to objConnection, objCommand, objRecordSet
Not tested.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform