Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get LDAP attributes used for users
Message
From
22/06/2004 06:29:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00915644
Message ID:
00915957
Views:
10
Sergey,
Then you might find these usefull as well (if like me with no DS server and want to setup a test one) :
On MSDN library search "Madam I'm ADAM". ADAM is the one I setup for testing.
Also ScriptoMatic from Scripting Guys help (links available from within Madam ...).
Note : Most samples use rootDSE and DefaultNamingContext. It'd be great to test them but unfortunately ADAM doesn't support it.
Also see my reply to myself for getting property list (original problem).
*ADO sample :
Local con As Adodb.Connection, rs As Adodb.Recordset
con = CreateObject('Adodb.Connection')
con.Provider = "ADsDSOObject"
con.Properties('User ID') = "adminID"
con.Properties('Password') = "pwd"
con.Properties('Encrypt Password') = .T. && port:636, .F. for port 389 access
con.Open("Active Directory Provider")

strFrom = 'LDAP://server/rootName' && ie: ADAM setup, 'LDAP://localhost/o=Microsoft,c=US'
rs = con.Execute([SELECT distinguishedName,displayName FROM ']+strFrom+[']+;
[ WHERE objectCategory = 'Person'])

rs.MoveFirst
DO while !rs.EOF
  ? rs.Fields(0).Value, rs.Fields(1).Value
  rs.MoveNext
enddo
Con.Close
* Get populated properties sample - assumes an ADAM setup with network authentication
* Mary Baker is added as stated in RevGuide_adam.DOC
Clear
#Define  ADSTYPE_INVALID 0
#Define  ADSTYPE_DN_STRING 1
#Define  ADSTYPE_CASE_EXACT_STRING 2
#Define  ADSTYPE_CASE_IGNORE_STRING 3
#Define  ADSTYPE_PRINTABLE_STRING 4
#Define  ADSTYPE_NUMERIC_STRING 5
#Define  ADSTYPE_BOOLEAN 6
#Define  ADSTYPE_INTEGER 7
#Define  ADSTYPE_OCTET_STRING 8
#Define  ADSTYPE_UTC_TIME 9
#Define  ADSTYPE_LARGE_INTEGER 10
#Define  ADSTYPE_PROV_SPECIFIC 11
#Define  ADSTYPE_OBJECT_CLASS 12
#Define  ADSTYPE_CASEIGNORE_LIST 13
#Define  ADSTYPE_OCTET_LIST 14
#Define  ADSTYPE_PATH 15
#Define  ADSTYPE_POSTALADDRESS 16
#Define  ADSTYPE_TIMESTAMP 17
#Define  ADSTYPE_BACKLINK 18
#Define  ADSTYPE_TYPEDNAME 19
#Define  ADSTYPE_HOLD 20
#Define  ADSTYPE_NETADDRESS 21
#Define  ADSTYPE_REPLICAPOINTER 22
#Define  ADSTYPE_FAXNUMBER 23
#Define  ADSTYPE_EMAIL 24
#Define  ADSTYPE_NT_SECURITY_DESCRIPTOR 25
#Define  ADSTYPE_UNKNOWN 26
#Define  ADSTYPE_DN_WITH_BINARY 27
#Define  ADSTYPE_DN_WITH_STRING 28

strServer       = "localhost"
strPort         = "389"
strRoot         = "o=Microsoft,c=US"

strContainer    = "OU=ADAM users"
strName         = "CN=Mary Baker"

strPath         = "LDAP://" + strServer + ":" + strPort + "/"
strMember       = strName + ;
  Iif(Empty(strContainer),"",",")+strContainer + ;
  Iif(Empty(strRoot),"",",") + strRoot

* Get reference to member
objMember    = Getobject(strPath+strMember)

objMember.GetInfo()
Local lHadError
For ix = 0 To objMember.PropertyCount-1
  On Error lHadError = .T.
  pEntry = objMember.Item(ix)
  On Error
  If lHadError
    lHadError = .F.
    Loop
  Endif
  ? pEntry.Name, ":"
  For Each v In pEntry.Values
    pValue = v
    Do Case
      Case pValue.AdsType = ADSTYPE_DN_STRING
        luValue = pValue.DNString
      Case pValue.AdsType = ADSTYPE_CASE_EXACT_STRING
        luValue = pValue.CaseExactString
      Case pValue.AdsType = ADSTYPE_CASE_IGNORE_STRING
        luValue = pValue.CaseIgnoreString
      Case pValue.AdsType = ADSTYPE_INTEGER
        luValue = pValue.Integer
      Case pValue.AdsType = ADSTYPE_PRINTABLE_STRING
        luValue = pValue.PrintableString
      Case pValue.AdsType = ADSTYPE_NUMERIC_STRING
        luValue = pValue.NumericString
      Case pValue.AdsType = ADSTYPE_BOOLEAN
        luValue = pValue.Boolean
      Case pValue.AdsType = ADSTYPE_UTC_TIME
        luValue = pValue.UTCTime
      Otherwise
        luValue = .Null.
    Endcase
    If !Isnull(luValue)
      ? Chr(9),luValue
    Endif
  Endfor
Endfor
Cetin


>George,
>
>I'm learning too how to work with active directory and LDAP. That's why I'm asking.
>
>>Sergey,
>>
>>As I said to Cetin, I'm just learning this my self. For me, however, it's returning the account string like this: CN=George Tasker,OU=Accounts,DC=domain,DC=company,DC=com
>>
>>The DC called domain is the domain name and the one that called company is has been replaced as well. This string is needed to get the members of array.
>>
>>Sorry I can't be more helpful. I'm sure I'll have more in the future.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform