Re: Retrieve attributes from Active Directory

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi Pictor,

Try if Winnt:// object works instead of ADO,

Sub ListUsers( strDomain )
Set objComputer = GetObject("WinNT://" & strDomain )
objComputer.Filter = Array( "User" )
For Each objUser In objComputer
WScript.Echo "Name: " & objUser.Name
WScript.Echo "Fullname: " & objUser.Fullname
WScript.Echo "Description: " & objUser.Description
WScript.Echo "AccountDisabled: " & objUser.AccountDisabled
WScript.Echo "IsAccountLocked: " & objUser.IsAccountLocked
WScript.Echo "Profile: " & objUser.Profile
WScript.Echo "LoginScript: " & objUser.LoginScript
WScript.Echo "HomeDirectory: " & objUser.HomeDirectory
WScript.Echo "" Next
End Sub

Dim strDomain
Do
strDomain = inputbox( "Please enter a domainname", "Input" )
Loop until strDomain <> ""

ListUsers( strDomain )
rgds
Babu

"Pictor" <Pictor@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F3065737-0328-4B23-9AE6-4FE3BFBBBACB@xxxxxxxxxxxxxxxx
Our client asked to have a trasparent login. So no user or password should
be
requested, after the windows login on the domain.
And it work with simple queries where I get attributes like "sn,
description, cn" or something.
But strangely some attributes, like sAMAccountName, give error if used in
the "SELECT" of the query (remember in the "WHERE" clause it works
perfectly!).

I thought it was an authentication problem.
Infact now I'm testing the page with this situation:
- 2 domains
- The domain 1 with the IIS server (with Integrated Authentication), and
where I'm logged in
- The domain 2 with the Active Directory Service

I though that, testing the pages from my user (logged on the NON AD
domain)
were causing problem (because the user is not recognized in the domain and
the queries are executed as Anonymous, and so there are limited access to
attributes, I suppose).
But I tried to execute the pages from the Active Directory Server
workstation (logged as Administrator) and these didn't work the same.

So I cannot understand where the problem is! :( :( :(
It seems not to be an authentication question.

So, the main errors are when I try an SQL query (via ADO) like:

"SELECT sAMAccountName, Name FROM 'LDAP://domain' WHERE
objectCategory='user' AND sAMAccountName='Igor' "

^^^ It start to load and the page, then, goes on timeout.

(but if I keep only the attribute Name it works!)

And when I try using GetObject("LDAP://domain";) it get the object.

Set object = GetObject("LDAP://domain";)

For Each item In object
Response.write item.Name
Next

The code like this works.
But if, in the For statement, I add:

Response.write item.Get("fullName") 'or another properties like 'Name'
itself

it gives me error (0x8000500D) telling me that the property is not found
in
the Active Directory cache.

I'm really desperate!
Have you any ideas?

I'm not skilled on AD, and I cannot find any possible solution :(

Help me! :..-(

Thank You!



.



Relevant Pages