#128249 - 2004-10-21 02:48 PM
search for a user in AD
|
jan
Getting the hang of it
Registered: 2004-07-07
Posts: 66
|
Hi,
How do I search for a user in AD. I need to search from e.g ou=kpdk,dc=q8int,dc=com and all sub containers. I've tried to look at ADsearch but I'm not sure how to make it work.
Hope someone can help me
Jan
|
|
Top
|
|
|
|
#128251 - 2004-10-21 03:24 PM
Re: search for a user in AD
|
jan
Getting the hang of it
Registered: 2004-07-07
Posts: 66
|
I have users in different containsers and I don't know in which container they exists. I need to find the full DN of the user in order to get order informations
|
|
Top
|
|
|
|
#128253 - 2004-10-21 03:51 PM
Re: search for a user in AD
|
Anonymous
Anonymous
Unregistered
|
Yes I looked at TranslateName and that doesn't seems to solve my problem. Is there a easy way to get DN?
|
|
Top
|
|
|
|
#128255 - 2004-10-21 04:32 PM
Re: search for a user in AD
|
Anonymous
Anonymous
Unregistered
|
I tried your script and it didn't worked. Isn't it because I need to type in the LDAP parameters? E.g. (LDAP://ou=kpdk,dc=q8int,dc=com)?
Jan
|
|
Top
|
|
|
|
#128256 - 2004-10-21 04:49 PM
Re: search for a user in AD
|
jan
Getting the hang of it
Registered: 2004-07-07
Posts: 66
|
My mistake, it works now. Many thanks for your help :-)
|
|
Top
|
|
|
|
#128257 - 2004-10-22 04:16 PM
Re: search for a user in AD
|
jan
Getting the hang of it
Registered: 2004-07-07
Posts: 66
|
Hi,
Now I want to use the var it returns, but when I use it I get an errormsg: IDispatch pointers not allowed in expressions!
Here is the code:
FUNCTION mailbox($getou) $mailbox=GETOBJECT("LDAP://$getou") ? "getobj @serror" ;? "Mailbox Information for $username:" ;? "User Information:" ;? "Display Name: " $mailbox.get("cn") ;? "Given Name: " $mailbox.get("givenname") ;? "Last Name: " $mailbox.get("sn") ;? "Alias: " $mailbox.get("uid") ;? "Mailbox Information:" ;? "Primary SMTP: " $mailbox.get("mail") ;? "X.400 Address: " $mailbox.get("textencodedoraddress") ;? "Home MTA: " $mailbox.get("home-mta") ;? "Home MDA: " $mailbox.get("home-mda")
ENDFUNCTION
function getOU($userName) DIM $dn,$objRootDSE,$strDomain DIM $objConnection,$objCommand DIM $objRecordSet $getOU = "Not Found" $objRootDSE = GETOBJECT("LDAP://RootDSE") $strDomain = $objRootDSE.Get("DefaultNamingContext") $objConnection = CREATEOBJECT("ADODB.Connection") $objConnection.Open ("Provider=ADsDSOObject;") $objCommand = CREATEOBJECT("ADODB.Command") $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = "<LDAP://" + $strDomain + ">;((saMAccountName=" + $userName + "))" + ";distinguishedName,name;subtree"
$objRecordSet = $objCommand.Execute
WHILE Not $objRecordSet.EOF $dn = $objRecordSet.Fields("distinguishedName").Value $getOU = $dn $objRecordSet.MoveNext LOOP
mailbox($getou)
ENDFUNCTION
BREAK on
? "Enter username: " GETS $username
getOU($username)
Hope you can help me
|
|
Top
|
|
|
|
#128258 - 2004-10-22 05:12 PM
Re: search for a user in AD
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Your Get's are objects. Objects cannot be outputed to a console.
$mailbox.get("cn")
|
|
Top
|
|
|
|
#128260 - 2004-10-25 11:10 AM
Re: search for a user in AD
|
jan
Getting the hang of it
Registered: 2004-07-07
Posts: 66
|
Hi,
Well I also get the error for these lines: $mailbox=GETOBJECT("LDAP://$getou")
and that's not to output to the console
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|