RodteX
(Fresh Scripter)
2004-04-06 12:33 AM
LDAP

Please, i need help!
See this code and help me:

$user_dep=GetObject("LDAP://cn=user.department,cn=user.samAccountname,ou=users,dc=aaa,dc=com")
use g: "\\server" +$user_dep + "$"

And not map...Why? Please


ShaneEP
(MM club member)
2004-04-06 01:05 AM
Re: LDAP

Well...Im not an LDAP expert but I couldnt get the query line you posted to return anything. There was also a missing "\" in the drive mapping statement. I was able to get the below code to work in my env....Give it a shot.

Code:
$user_dep=GetObject("LDAP://CN="+@FullName+",OU=users,DC=aaa,DC=com")
use g: "\\server\"+$user_dep.department+"$"



RodteX
(Fresh Scripter)
2004-04-06 01:23 AM
Re: LDAP

No Citrix, error in use..????...


NTDOCAdministrator
(KiX Master)
2004-04-06 01:25 AM
Re: LDAP

Rod

Probably the easiest thing to do is copy and save this script from Chris.

KiXforms - Active Directory Browser
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=91082


You will need to download and install KiXforms DLL from here
http://www.kixforms.com

Then when you run it you can browse to the object you want and copy/paste the LDAP location into your script.


RodteX
(Fresh Scripter)
2004-04-06 01:56 AM
Re: LDAP

Please NTDOC!
I did not understand.
What I must after make to catch the code? And the archive kixforms.dll? What I must make with it?

Forgive me, I am new in kix


NTDOCAdministrator
(KiX Master)
2004-04-06 02:08 AM
Re: LDAP

copy the script that Chris posted on the board at the link I provided.

Then save that script in a text file and give it a name.

Then download the KIXFORMS from the KiXforms link I provided.

Open the file and extract it to your local system. Copy the DLL to your %windir%\system32 folder then run

REGSVR32.EXE KIXFORMS.DLL to register it.

Then in a DOS window where you saved the file from Chris.

run something like

C:\SCRIPTS\KIX32.EXE ADBROWSER.KIX

Which should then open a GUI window you can use to browse your AD and copy paths with it.


RodteX
(Fresh Scripter)
2004-04-06 02:23 AM
Re: LDAP

Whel....!!!!
I don't no...
Error in line 29 and 43 and 44...i'm desesperaid
Sorry friend...


NTDOCAdministrator
(KiX Master)
2004-04-06 02:43 AM
Re: LDAP

Please post what your code is. I don't know what you have on those lines.

Please use the CODE TAGS of Instant UBB Code to keep the code formatting when posting.


RodteX
(Fresh Scripter)
2004-04-06 02:46 AM
Re: LDAP

Whel, i'm copy code to this site.
CTRL+C / CTRL+V...accurately equal


NTDOCAdministrator
(KiX Master)
2004-04-06 02:56 AM
Re: LDAP

Rod,

Please post the contents of your script here on the board so that we can see what is on those lines you said give errors.

We can't see the code, so we have no idea what is going on.


RodteX
(Fresh Scripter)
2004-04-06 03:05 AM
Re: LDAP

no friend, sees well, forgives me:
this error is giving in script of chris s., that you indicated me above.


Sealeopard
(KiX Master)
2004-04-06 03:24 AM
Re: LDAP

Please read ABC's of KiXtart board etiquette and message to new forum users , especially Section F.

It doesn't help us if you say there's an error and then don't even adequately describe the error. did youfollow the instructions given to you and did each step succeed? Did the DLL register correctly? Do you even see a form? Did you copy the code correctly, see the FAQ forum for info on this.


ShaneEP
(MM club member)
2004-04-06 03:30 AM
Re: LDAP

Rod...

The code snippet I posted does work. I tested it in my domain at work. My guess is you dont know what the correct path of the user object is and thats probably why Doc is trying to get you to use the kixforms script to get the path. Is the user object in the users OU or is it in a different OU? That will effect where you query the dept from.


RodteX
(Fresh Scripter)
2004-04-06 03:35 AM
Re: LDAP

Sorry Sealeopard...
Citrix and NTDOC, this error is in line 29 =
$imglarge.imagesize = 32,32



Sealeopard
(KiX Master)
2004-04-06 03:50 AM
Re: LDAP

Yo still did not answer any of the other questions. Did the DLL get registered correctly? What Kixtart and KiXforms version?

RodteX
(Fresh Scripter)
2004-04-06 02:19 PM
Re: LDAP

Ok Sealeopard, thanks...
DLL registered ok and versions of kix is:
Kixtart - 4.22
Kixforms - 2.2.0


Chris S.
(MM club member)
2004-04-06 02:50 PM
Re: LDAP

I think that this is what you're ultimately after...

Code:

$user_dep = GetObject("LDAP://CN=USERNAME,OU=users,DC=aaa,DC=com").Department
use g: "\\server\" + $user_dep + "$"




RodteX
(Fresh Scripter)
2004-04-06 03:09 PM
Re: LDAP

No map Chris...


Chris S.
(MM club member)
2004-04-06 03:16 PM
Re: LDAP

Is the value for $user_dep correct?

Les
(KiX Master)
2004-04-06 03:19 PM
Re: LDAP

Rodtex,
You are not very helpful with the level of info you give. Why don't you break up the task into sections and test each one, repiorting the results of each.

What does the var $user_dep return?
Does it work if you hard code the USE statement?


RodteX
(Fresh Scripter)
2004-04-06 03:36 PM
Re: LDAP

Whel, a value of return is: $user_dep...
I don't understending...


Chris S.
(MM club member)
2004-04-06 03:55 PM
Re: LDAP

Run this and post your results...

Code:

$User = GetObject("LDAP://CN=USERNAME,OU=Users,DC=aaa,DC=com")
@ERROR " | " @SERROR ?
"Username: " $User.samAccountName ?
"Department: " $User.Department ?



RodteX
(Fresh Scripter)
2004-04-06 04:17 PM
Re: LDAP

Ok Chris, tks...
@error = -2147221014 | Moniker can not open file

Username: blanck
Department: blanck


Chris S.
(MM club member)
2004-04-06 04:40 PM
Re: LDAP

Please run this script and post the results...

Code:

Break On

$nul=SetOption("WrapAtEOL","On")

$FQDN = TranslateName (3,"",3,"@LDOMAIN\@USERID",1)
If @ERROR
@ERROR " | " @SERROR ?
Else
"Fully Qualified Domain Name: " + $FQDN ?

$User = GetObject("LDAP://" + $FQDN)
If @ERROR @ERROR " | " @SERROR ? EndIf
"Username: " $User.samAccountName ?
"Department: " $User.Department ?
EndIf

Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)

Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText

$Error = 0
$ErrorText = ""
$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)
endif
endif
endif
$TranslateName = $ReturnName
If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
Endfunction



Howard Bullock
(KiX Supporter)
2004-04-06 04:48 PM
Re: LDAP

I find that:
GetObject("LDAP://CN=USERNAME,OU=Users,DC=aaa,DC=com")

will not work when executing this code on a client computer unless you also specify a domain or server name as part of the LDAP string.


GetObject("LDAP://NetBIOSDomain/CN=USERNAME,OU=Users,DC=aaa,DC=com")
or
GetObject("LDAP://server/CN=USERNAME,OU=Users,DC=aaa,DC=com")

This tells where the LDAP bind should take place.


RodteX
(Fresh Scripter)
2004-04-06 06:28 PM
Re: LDAP

Hey Chris, very tks to help me...
Error in execute script is:
9 | the address of the blocks of storage control is invalid

And Howard, this option not valid, no map...


ShaneEP
(MM club member)
2004-04-06 06:46 PM
Re: LDAP

I have found that I have to use @FullName to get results...The USERID does not work. Not sure if it is just my enviroment...But if not, then you all are telling him to use USERID which may not be working.

Chris S.
(MM club member)
2004-04-06 07:50 PM
Re: LDAP

Well, with the TranslateName UDF we are inputing the user information using WINNT and attempting to translate to a fully-qualified LDAP path.

I think at this point we need some more basic information.

What is the operating system of the computer running the script?

What is the directory environment (2000 AD, 2003 AD, NT 4)?


RodteX
(Fresh Scripter)
2004-04-06 07:54 PM
Re: LDAP

AD 2003

Chris S.
(MM club member)
2004-04-06 07:58 PM
Re: LDAP

and...

What is the operating system of the computer running the script?


RodteX
(Fresh Scripter)
2004-04-06 08:04 PM
Re: LDAP

Windows 98, Windows 2000 and Windows XP (Brazilian version too)

Chris S.
(MM club member)
2004-04-06 08:12 PM
Re: LDAP

Which OS are you testing on right now?

ADSI is not installed on Windows 98.


RodteX
(Fresh Scripter)
2004-04-06 08:22 PM
Re: LDAP

Win 2K Pro

Chris S.
(MM club member)
2004-04-06 08:29 PM
Re: LDAP

Are you able to run the script the NTDOC talked about in this post: http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB13&Number=116164&Forum=UBB13&Words=KiXforms%20-%20Active%20Directory%20Browser&Match=Entire%20Phrase&Searchpage=0&Limit=25&Old=1week&Main=116161&Search=true#Post116164


RodteX
(Fresh Scripter)
2004-04-06 09:08 PM
Re: LDAP

Whel....!!!!
I don't no...
Error in line 29 and 43 and 44...
I give up


Sealeopard
(KiX Master)
2004-04-06 09:19 PM
Re: LDAP

I just copied the script and ran it. There's nothign wrong with the script, which makes me believe that you didn't copy it correctly. See the FAQ Forum on how to copy/paste code form the board.

RodteX
(Fresh Scripter)
2004-04-06 09:23 PM
Re: LDAP

Hey Sealeopard,
I need CTRL+C/CTRL+V, but i don't understend, no work...
Sorry...and tks for help


ShaneEP
(MM club member)
2004-04-06 09:28 PM
Re: LDAP

Try this....

Click on the the link below and download the script and run it. As long as you have the kixforms.dll registered it should work fine.

AD_Browser.kix

Once you run the AD_Browser.kix script you should be able to browse to a user and copt the correct LDAP path of that user.


ShaneEP
(MM club member)
2004-04-06 09:39 PM
Re: LDAP

Better yet...Try downloading this script. It is a stripped down version of the script that Chris posted above using the TranslateName UDF. That way it will work for any user no matter their AD directory.

ldap_dept.kix

The only thing you have to change in the script is the server to map the drive to...It is currently \\server\ and you will need to change this to your server name. Besides that there should be no needed changes. See if it works.


Kdyer
(KiX Supporter)
2004-04-06 10:17 PM
Re: LDAP

A tip..

Copy the script to the clipboard.. Paste into Word/WordPad. Copy from Word/WordPad, and paste into NotePad. The code formatting should come out right.

Kent


Howard Bullock
(KiX Supporter)
2004-04-07 03:09 AM
Re: LDAP

I did not see what version of KiXtart you are using. With all the errors you mention with a script that others can execute, it makes me think that you are not running 4.02 or higher. Can you confirm the version of KiXtart you are running?

Les
(KiX Master)
2004-04-07 03:29 AM
Re: LDAP

Quote:

Ok Sealeopard, thanks...
DLL registered ok and versions of kix is:
Kixtart - 4.22
Kixforms - 2.2.0




Howard Bullock
(KiX Supporter)
2004-04-07 02:15 PM
Re: LDAP

Darn, I hate being worng.

Les
(KiX Master)
2004-04-07 05:24 PM
Re: LDAP

Quote:

worng (sp)



Just like Fonzie, you cannot even bring yourself to say it.


Chris S.
(MM club member)
2004-04-07 06:43 PM
Re: LDAP

I had another thought. Give this a try...

Code:

Break On

$nul=SetOption("WrapAtEOL","On")

$objADSystemInfo = CreateObject("ADSystemInfo")
If @ERROR
@ERROR " | " @SERROR ?
Else
"Fully Qualified User Name: " + $objADSystemInfo.UserName ?

$User = GetObject("LDAP://" + $objADSystemInfo.UserName)
If @ERROR @ERROR " | " @SERROR ? EndIf
"Username: " $User.samAccountName ?
"Department: " $User.Department ?
EndIf



ShaneEP
(MM club member)
2004-04-07 07:12 PM
Re: LDAP

nice one Chris. Seems to work great for me. I went ahead and uploaded a stripped down copy for our clipboard challenged friend. All that needs changed is the server in the use statement.

ldap_dept2.kix