Page 1 of 2 12>
Topic Options
#113689 - 2004-02-10 01:49 PM Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Hey,

I cannot get the LDAP query work:

$TextBox.Text = 'domain\cyrus'
$ldap = TranslateName(1, @domain, 3, $TextBox.Text, 1)
$UserProperties = GetObject("LDAP://ldap.home.com"+$ldap[0])

The only way i can do an ldap search is to setting up a Directory Service in outlook express, and using the address bok to make searches.

Dont know anything about the ldap server it self, or how its configured etc.

I just need to get user info from the the ldap global directory.

How 2 do?



_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113690 - 2004-02-10 02:07 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
try: $UserProperties = GetObject("LDAP://ldap.home.com/"+$ldap[0]) Notice the addition of the "/" after the domain.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113691 - 2004-02-10 02:25 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Noop, its just dont work. :-(

From unix i do this:
ldapsearch -h ldap.home.com -p 389 -b o=home userid=cyrus

And it gives me:

cn=cyrus,o=home
objectClass=top
objectClass=person
objectClass=organizationalPerson
cn=cyrus
cn=Cyrus Keyrus
cn=Cyrus MC Keyrus
sn=Keyrus
l=BN
ou=IS/IT
telephoneNumber=+4465421154

So it works doing query from Unix environment.

From Windows using kix i do this:

$TextBox.Text = 'domain\cyrus'
$ldap = TranslateName(1, @domain, 3, $TextBox.Text, 1)
$UserProperties = GetObject("LDAP://ldap.home.com/"+$ldap[0])

$pc = $UserProp.Items.Add("DistinguishedName")
$pc.SubItems(1).text = $userProperties.distinguishedName

$pc = $UserProp.Items.Add("Account")
$pc.SubItems(1).text = $userProperties.SAMAccountName

Nothing happens

Any ideas?
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113692 - 2004-02-10 02:46 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Please use @error and @Serror to return the error of the GetObject. You should also try outputing each of your variables to see that they contain what you think they should.

$TextBox.Text is not a valid variable name. Are you using Kixforms?

This code works for me using Kix32. Please start with this for testing and let me know the result. Code:
break On
? @kix
$TextBox = 'domain1\user1'
? $TextBox
$ldap = TranslateName(1, @domain, 3, $TextBox, 1)
? $ldap
?
? "LDAP://tycoelectronics/" + $ldap
$UserProperties = GetObject("LDAP://domain1/"+$ldap)
? "@error @serror"
? $userProperties.SAMAccountName

Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $NameTranslate, $ReturnName

$ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate")
if @Error = 0
$NameTranslate.Init ($InitType, $BindName)
if @Error = 0
$NameTranslate.Set ($LookupNameType, $LookupName)
if @Error = 0
$ReturnName = $NameTranslate.Get($ReturnNameType)
if @Error <> 0
Writelog("TranslateName: Get error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: Set error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: Init error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: CreateObject error " + @error + " " + @serror)
endif
$TranslateName = $ReturnName
Endfunction




_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113693 - 2004-02-10 05:43 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Yes im using kixforms where $TextBox.Text is representing
"domain\user"

I try your script, but it gives me error:

ERROR : unknown command [Writelog]!
Line : 33

_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113694 - 2004-02-10 05:59 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
The WriteLog function was missed in your script.
I put it there. now i got following error:

LDAP://ldap.home.com/
-2147463168 An invalid directory pathname was passed

and the log :

2004/02/10 17:50:52 - TranslateName: Init error -2147352567 COM exception error "Init" ((null) - (null)) [-2147352567/80020009]
2004/02/10 17:50:52 - TranslateName: (1, ResourceDomain, 3, Domain\cyrus, 1)



_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113695 - 2004-02-10 08:19 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Now we are getting somewhare.

TranslateName: Init error -2147352567 COM exception error "Init" ((null) - (null)) [-2147352567/80020009]


Means that the translate name function could not init the COM object using "ResourceDomain" (@domain). What happens if you use the Netbios name of the account domain where the account lives? By the way...you are executing this script under the security contextr of an active directory user account that has access to this domain - right?

You can try using different binding values.

bind to the logon domain:
$Name2 = TranslateName (1, @LDomain, 3, $Name1, 1)

bind to a server:
$Name2 = TranslateName (2, "\\server", 3, $Name1, 1)


Is your resource domain a W2K domain in the forest?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113696 - 2004-02-10 08:37 PM Re: Can not get LDAP query to work.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You don't even mention the OS or KiXtart version used. Please read ABC's of KiXtart board etiquette and message to new forum users and amend you post accordingly.
_________________________
There are two types of vessels, submarines and targets.

Top
#113697 - 2004-02-11 04:57 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Sealeopard : My apology to u, of course I should read the forum board msg first. My bad, forgive me.

Howard Bullock : You are so helpful and your way to explain things are so pedagogical. I wish u the best and success whatever you do and where ever u are :-)

/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113698 - 2004-02-11 05:09 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Im using a Windows XP client, the environment Im working in is company enterprise, with mixed domain environment, Windows NT/2000, part of that AD, UNIX domain and development environment, SUN, HP-UX, Several domain and resource domain as per company sites. Im using Kix 4.22.0.0
and KixForms 2.3.0.41 - Hope i dont missed anything
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113699 - 2004-02-11 05:49 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Where do we stand on the testing of different TranslateName bindings? Any success? You process should work if the script can return the DN for use in the GetObject call.

Checklist:
1. execute code under and Active Directory account.
2. execute code from a computer that is a member of the AD forest.
3. report results.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113700 - 2004-02-11 06:12 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
The domain user account seems to be on the NT4 DC. The target domain has 2 DC and several BDC. There is a resource domain too for this logon domain. Im not familiar whit Rdomian and what is good for. In this case the account is not an AD account, but just a NT4 PDC account.

I dont get the TranslateName part of kix, how should the output look like?

I cannot make it work. it dosnt matter if i use Ldomain or Rdomain or DC servers ip or dns address.

Getting realy confused

_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113701 - 2004-02-11 07:49 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
TranslateName was developed to ease the use of LDAP with active directory. It's intended purpose is accept the domain\user name format and then return the workstation's or user's "Canonical Name" or "Distinguished Name". Neither of these seem like they would apply to you if you are referencing a user account on a NT4 domain.

Examples:
Code:

Wksta Canonical Name.....: gb.tyco.com/Organisations/750-Swindon/OnSite/GBS0217
Wksta Distinguished Name.: CN=GBS0217,OU=OnSite,OU=750-Swindon,OU=Organisations,DC=gb,DC=tyco,DC=com

User Canonical Name....: tyco.com/0001 - Tyco Electronics/0401 - Europe-Mideast-Africa/0414 - Northern Europe (Area)/0433 - Tyco Electronics UK Limited/user64
User Distinguished Name: CN=user64,OU=0433 - Tyco Electronics UK Limited,OU=0414 - Northern Europe (Area),OU=0401 - Europe-Mideast-Africa,OU=0001 - Tyco Electronics,DC=tyco,DC=com



NT4 is not an LDAP server and does not understand NameTranslate method. Please see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iadsnametranslate.asp


If you could better describe what you wish to accomplish, I may be better able to assist you. Is the LDAP server you wish to query a Windows 2000 domain controller? Why are you trying to look up LDAP properties on an NT4 account (or did I misunderstand you)?

In your original post you reference "ldap.home.com". What kind of server is this? What is your client operating system? IS ADSI installed?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113702 - 2004-02-12 04:00 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Finaly i got some clearness regarding the infrastructure. The LDAP server is an UNIX SUN machine, which provides the Global Directory with needed info and data. The Global Directory uses the X500 protocol.
Sinces I could use Outlook Express to setup a ldap account pointing to target ldap server, and get info data for employes, I thought I could use KIX to do ladpsearch to collect data from this ldap server.
So now I have to figure out how Outlook Express works, since I can use it to do ldapsearch...

If Outlook Express can, then KIX should do that too...I hope.

/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113703 - 2004-02-12 06:36 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
If we forget the LDAP for a moment, is it possible to get user data via Exchange/mail server? We have the userid which meens: userid@company.com
Regarding the ADSI, Is it included in Win XP Pro, as it is in Win 2000?

Found on your website a tools you have maked, using pearl and ADSI called : LookupMailboxFromAccount.exe

Unfortunately I can not get it, seems not to be there anymore, or mayby u have moved it from there.

Wonder if that could help?

_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113704 - 2004-02-12 07:44 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think that you are using an OLD URL. Please click the link in my signature line to access my web site and navigate from there.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#113705 - 2004-02-16 06:12 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Howard, Your pearl "LookupMailboxFromAccount" works perfectly

Now I need some help to write a kix script doing the same thing, this without using any query to LDAP servers.

Thanx /C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113706 - 2004-02-16 06:34 PM Re: Can not get LDAP query to work.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might want to restate what exactly yo try to achive. We've helped you to solve the issue using LDAP and now you say you don't want to use LDAP?
_________________________
There are two types of vessels, submarines and targets.

Top
#113707 - 2004-02-17 06:35 PM Re: Can not get LDAP query to work.
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Solved?, Its not sovled!!!. The metod that was discribed above, is working ONLY if u have Win2000 with AD and a Windows based LDAP server.
As i mentioned above, the LDAP server here is a UNIX SUN Solaris server, which somehow works togher with global directory service(X500 protocol) and ofcures with the Windows world (Windows domain servers and services of all kind!!!).
The only way i could do a ldap search from an Win2000/XP client was to setup and dirctory service using outlook express.
Sinces Im just a beginer i needed some guidness and help to solve this. And caues i couldnt get this work in a KIX script, I try to find another way to make it work.

However u can forget it, I will fix it somehow!
/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#113708 - 2004-02-17 11:02 PM Re: Can not get LDAP query to work.
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If you can do this with Outlook Express, I would suspect you should be able to do it in KiXtart if there is an appropriate COMable LDAP interface to your Unix LDAP server. I am not sure if ADSI will work or not, but if Outlook Express can do it the pieces should exist to accomplish the goal.

Unfortunately I do not know where to begin since I have no thing to test...
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1077 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.06 seconds in which 0.017 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org