Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting Script to VFP
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01243994
Message ID:
01244008
Views:
19
I don't have Active Directory here, so I didn't try the script.

But on the Russian web-site Vlad Kolosov states, that this code works for him:
strUserName = "Kolosov"   
  objConnection = CreateObject("ADODB.Connection")   
  objConnection.Open("Provider=ADsDSOObject;")  
    
  objCommand = CreateObject("ADODB.Command")   
  objCommand.ActiveConnection = objConnection   
  objRootDSE = GetObject("LDAP://RootDSE")   
  strDNSDomain = objRootDSE.Get("defaultNamingContext")   
  objCommand.CommandText = "<LDAP://"+strDNSDomain+">;(&(objectCategory=person)(objectClass=user)(sAMAccountName=" + strUserName + "));samAccountName;subtree"   
    
  objRecordSet = objCommand.Execute   
    
  IF objRecordset.RecordCount = 0  
  	?"sAMAccountName: " + strUserName + " does not exist."   
  ELSE    
  	?strUserName + " exists."   
  ENDIF   
    
  objRecordSet.MoveFirst  
  Do WHILE NOT objRecordSet.EOF  
      strDN  = objRecordSet.Fields("distinguishedName")   
      strSAM = objRecordSet.Fields("sAMAccountName")  
      ?strSAM.value + ' ' + strDN.value + ''  
      objRecordSet.MoveNext  
  ENDDO  
    
  objConnection.Close
>Hi Naomi,
>
>I had do almost the exact same conversion, but get an "unspecified" error on this line:
>
>objRecordSet = objCommand.Execute()
>
>
>If I can get the syntax correct to get objRecordset populated (by calling the objCommand.Execute command, I'd be set (I'll be stuffing the results into a table and processing from there).
>
>As always, I appreciate your input. If you are able to get past that error (the line that calls the execute command), please let me know! :-)
>
>Thanks,
>
>Patric
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform