• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1125
  • Last Modified:

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

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
heuvels
Asked:
heuvels
  • 6
  • 5
1 Solution
 
LanBuddhaCommented:

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
 
heuvelsAuthor Commented:
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
 
LanBuddhaCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
heuvelsAuthor Commented:
Ok yes thats clear

But i need the info computer location  field

do you have that query ?
0
 
LanBuddhaCommented:
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
 
heuvelsAuthor Commented:
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
 
LanBuddhaCommented:
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
 
heuvelsAuthor Commented:
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
 
LanBuddhaCommented:
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
 
heuvelsAuthor Commented:
ok i go download the ms stuff

Amazing thanks for the answers

i will report as soon as possible when i now more
0
 
heuvelsAuthor Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now