Solved

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

Posted on 2006-11-28
13
1,110 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allStar challenge 1 52
groupSum6 challenge 6 77
Installed softare without GUID 6 66
Help to convert powershell script into a gui 9 141
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
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.
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 …
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now