Solved

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

Posted on 2006-11-28
13
1,112 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
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Insert parts by customer 12 42
collection output issue 9 37
Do Wend Macro not working 22 35
statistics basics sources 2 8
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

828 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