Solved

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

Posted on 2006-11-28
13
1,113 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
13 Comments
 
LVL 2

Expert Comment

by:LanBuddha
ID: 18030638

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
ID: 18032465
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
ID: 18033113
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!

 

Author Comment

by:heuvels
ID: 18035048
Ok yes thats clear

But i need the info computer location  field

do you have that query ?
0
 
LVL 2

Expert Comment

by:LanBuddha
ID: 18036257
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
 

Author Comment

by:heuvels
ID: 18037004
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
ID: 18037205
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
ID: 18037488
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
ID: 18037642
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
ID: 18037667
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
ID: 18038135
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

749 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