Solved

ADSystemInfo with vbs logonscript Retrieve the %CleintName% in a Citrix session

Posted on 2006-11-28
13
1,109 Views
Last Modified: 2009-07-29
So i have bean buzi a long time, to make a connection with a terminal server with a Citrix ICA cleint

Ok Citrix workt perfect with only the published apps, but 1 thing is not always working and that are the autocreated printers (most of time yes it works)

So i want within my vb script read with the ADSystemInfo  
strDistinguishedComputerName = objADSystemInfo.ComputerName

now i want to read the location field from the Cleintcomputer in the ad (i now its name in the terminal session %Cleintname%) so i want to now  where the user is loged on to give him the printer nearest him.


simple question how to read the compleet strDistinguishedComputerName with the %Cleintname% as atribute ?
0
Comment
Question by:heuvels
  • 6
  • 5
13 Comments
 
LVL 2

Expert Comment

by:LanBuddha
Comment Utility

How about

Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")

It's not AD but it will give you the name of the computer.
0
 

Author Comment

by:heuvels
Comment Utility
Yes i now the Clientname al ready but i want to read the location field from the AD(so i can see where the user is sitting to give him the nearest printer)

i'm using a vb script for the user's local desktop and give him the printer nearest to him based on the location field in the ad

i want to do the same for the citrix terminal stuff
0
 
LVL 2

Expert Comment

by:LanBuddha
Comment Utility
This will get messy really quick. You have to build the path to the object you want to query.

On Error Resume Next

Dim Path
Dim UserName
Dim objUser

UserName = "LanBuddha"
Path = "LDAP://cn=" + UserName + ",ou=management,dc=LanBuddha,dc=com"

Set objUser = GetObject (Path)
 
Wscript.Echo "Profile Path: " & objUser.ProfilePath
Wscript.Echo "Script Path: " & objUser.ScriptPath
Wscript.Echo "Home Directory: " & objUser.HomeDirectory
Wscript.Echo "Home Drive: " & objUser.HomeDrive


0
 

Author Comment

by:heuvels
Comment Utility
Ok yes thats clear

But i need the info computer location  field

do you have that query ?
0
 
LVL 2

Expert Comment

by:LanBuddha
Comment Utility
On Error Resume Next

Dim Sh
Dim sys
Dim Path
Dim objComputer

Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")

Path = "LDAP://Server/cn=" + sys + ",cn=computers,dc=Domain,dc=com"

Set objComputer = GetObject (Path)
 
Wscript.Echo "Location: " & objComputer.location
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:heuvels
Comment Utility
what do you mean with ://Server/   ????

i had done this  (i work with ie to show it)

If IsTerminalServerSession = False Then             ''this is working perfect and return's also the Clientname(strName)
      Set objComputer = GetObject("LDAP://" & strDistinguishedComputerName)
else
   Dim Path

   Path = "LDAP://CN=" & strName  & ",OU=Met SP2,OU=Office 2003,OU=Office CD 1 2 PC OU,OU=De Voord,DC=zorg,DC=tld"          'incl the complete OU
   
   writeoutput "test 1 : " & Path
   Set objComputer = GetObject (Path)      '' after this line the script stops ??
    writeoutput "Domain test2: " & objComputer.Location        '' the location still is empty on return
    Wscript.Sleep 5000     '' to see the tings are working wel
end if


but stil nothing sniff
0
 
LVL 2

Expert Comment

by:LanBuddha
Comment Utility
The server is the domain controller you are going to query for the computer account.

According to your path you do not keep computer accounts in the computer OU?

So if my Domain Controller was BIGDOG and the computer accounts were in the computer OU:

On Error Resume Next

Dim Sh
Dim sys
Dim Path
Dim objComputer

Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")

Path = "LDAP://BIGDOG/cn=" + sys + ",cn=computers,dc=Domain,dc=com"

Set objComputer = GetObject (Path)
 
Wscript.Echo "Location: " & objComputer.location
0
 

Author Comment

by:heuvels
Comment Utility
Yes now its working i move the comp account to the computer OU

but i have the OU structer like this OU=Met SP2,OU=Office 2003,OU=Office CD 1 2 PC OU,OU=De Voord

1 OU = De Voord
sub ou in that  Office CD 1 2 PC OU
sub on that  Office 2003
sub on that  Met SP2

i have now this

On Error Resume Next

Dim Sh
Dim sys
Dim Path


Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")

Path = "LDAP://ELBS01/cn=" + sys + ",OU=Met SP2,OU=Office 2003,OU=Office CD 1 2 PC OU,OU=De Voord,dc=zorg,dc=tld"

Set objComputer = GetObject (Path)
 
writeoutput "Location: " & objComputer.location

Wscript.Sleep 500



the objComputer.location stay's empty now
when  i use this then its working (and moving the comp account  :-) )?

Path = "LDAP://ELBS01/cn=" + sys + ",cn=computers,dc=zorg,dc=tld"


what im doing wrong !
0
 
LVL 2

Accepted Solution

by:
LanBuddha earned 125 total points
Comment Utility
Your path is wrong.

In the ADSI SDK from Microsoft is a program called ADSVW.exe that will let you explore active directory. This program will give you the path to the OU.

You need to get the path to place in your code.
0
 

Author Comment

by:heuvels
Comment Utility
ok i go download the ms stuff

Amazing thanks for the answers

i will report as soon as possible when i now more
0
 

Author Comment

by:heuvels
Comment Utility
Ahh yes working

i renamed this OU Office CD 1 2 PC OU to Office PC

and now its working ?

Yes say it mayby a strange thing that the combination of numbers are not supported ore somthing

but thanks for your support
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now