Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADSI in VFP
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
ADSI in VFP
Miscellaneous
Thread ID:
00314125
Message ID:
00314125
Views:
87
I have been doing some research into ADSI in VFP to try to create a simple "Add User" and "Add to Group" function without resorting to third party products or DLL's.

I have searched the UT archives for similar messages and know that Ed Rauh and Paul Vlad Tatava have extensive knowledge in this area and that Paul has a library routine that performs a similar function.

I attach some code that will work in VFP6.0 (once the ADSI SDK has been brought down and installed). It should be self explanatory. It gives inconsistent results in WinNT Workstation and WinNT Server.

Anyone got any ideas about what is going on ?

Code follows
----------------------
clear
#DEFINE thiscomputer "YourComputer"
dom=GetObject("WinNT://"+thiscomputer)
on Error do ErrHand
? "USERS"
? "-----"
dime aUser[1]
i=1
for each usr in dom
   if usr.class="User"
      xxx=usr.Groups
      usrgrp=''
      for each grpx in xxx
         usrgrp=usrgrp+grpx.name+","
      endfor
      ? usr.name+" ("+usrgrp+")"
      aUser[i]=usr.name
      i=i+1
      dime aUser[i+1]
   endi
endfor
dime aUser[i-1]
?
? "GROUPS"
? "------"
for each usr in dom
   uMemb=''
   if usr.class="Group"
      grp=GetObject("WinNT://"+thiscomputer+"/"+chrtran(trim(usr.name),' ','_'))	
      for i=1 to alen(aUser,1)
         if grp.Ismember(aUser[i])
            uMemb=uMemb+aUser[i]+','
         endi	
      endfor
      ? usr.name+" ("+uMemb+")"
   endi
endfor
return

Procedure ErrHand
return
Next
Reply
Map
View

Click here to load this message in the networking platform