Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP Retrieval of AD Information

Status
Not open for further replies.

ChuckG

MIS
Feb 28, 2001
211
US
Hi,

I've got a programmer here who's looking to be able to retrieve Active Directory information from VFP (6 or 9).

He will have the username of the person he's wanting to retrieve information about, but isn't sure how to open a connection to the local AD Controller to retrieve said information.

I've written one in ASP to do this, but he doesn't have the actually connection information for VFP.

Any suggestions?

For an example, say he's looking for the email address for a user named ChuckG and the AD Controller is: DC1

Thanks
ChuckG

ChuckG
-=-=-=-
Midnight Club BBS
telnet midnight-club.org
 
Can you post your asp example, someone here might be able to work it out for you - I can't I don't have an AD to play with!

Regards

Griff
Keep [Smile]ing
 
Here's what I'm using on my ASP page to retrieve the AD
displayname and mail values.

<%
nt_name1 = Request.ServerVariables("LOGON_USER")
On Error Resume Next

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 displayName,mail FROM 'LDAP://dc=domain,dc=com' WHERE objectCategory='user' " & _
"AND sAMAccountName='"& nt_name1 &"'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
fName = objRecordSet.Fields("displayName")
Wscript.Echo objRecordSet.Fields("displayName").Value
fEmail = objRecordSet.Fields("mail")
Wscript.Echo objRecordSet.Fields("mail").Value
objRecordSet.MoveNext
Loop
%>


Thanks


ChuckG
-=-=-=-
Midnight Club BBS
telnet midnight-club.org
 
Don't know if this will help at all, but it may provide a bit of an example:
Code:
oManager = GETOBJECT("winmgmts:")

x = ;
   oManager.InstancesOf("Win32_NetworkLoginProfile")

DIMENSION aItems[x.count]
zzz = 1
FOR EACH Adapter IN x
   aItems[zzz] = Adapter
   FOR EACH Property IN Adapter.Properties_ 
      STORE Property.name + Alltrim(Str(zzz)) TO cVar
      IF Property.IsArray
         DIMENSION &cVar[1]
         &cVar = Property.Value 
      ELSE 
         &cVar = Property.Value 
      ENDIF 
   NEXT 
   zzz = zzz + 1 
NEXT 
LIST MEMO TO stuff.txt NOCONSOLE 
MODIFY FILE stuff.txt NOWAIT


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top