#67160 - 2002-06-17 06:13 PM
InContainer Script
|
joewilson
Lurker
Registered: 2002-06-17
Posts: 3
Loc: Stamford
|
Hi,
I am using the InContainer script written by Howard Bullock to check the machine account of users when they log onto the domain to see if it is in the Computers OU. That is working great and I am generating an email to the Help Desk for such users. The email has the @wksta @userid variables. The problem is the @userid variable only returns the users logon name not the DN or distinguished name. Havin the DN would be helpful since this will help the Help Desk know where the computer account should be moved to. Any suggetions would be greatly appreciated.
Joe
|
|
Top
|
|
|
|
#67161 - 2002-06-17 06:19 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Good to see you here Joe.
Since you are using Incontainer() you have already loaded TranslateName(). You can simply call: code:
$DN = TranslateName (3, "", 3, "@LDomain\@UserId", 1) ? "DN = " + $DN[0] ? "Error = " + $DN[1] ? "ErrorText = " + $DN[2]
to get the DN of the user. [ 17 June 2002, 18:21: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#67163 - 2002-06-17 06:26 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
DN = distinguished name (LDAP)
DN for my computer: CN=BULLOCKHA,OU=test,OU=9826,OU=NCS,OU=Machines,DC=us,DC=tycoelectronics,DC=com'
|
|
Top
|
|
|
|
#67164 - 2002-06-17 08:02 PM
Re: InContainer Script
|
joewilson
Lurker
Registered: 2002-06-17
Posts: 3
Loc: Stamford
|
I implemented Howard Bullock's suggestion and that certainly does give me the user DN. Now my problem is that I am using blat.exe to generate the email to the Help Desk and cannot successfully pass the $DN variable to the email. Here is the code from the login script. Below is the code from the batch file being called.
$DN = TranslateName (3, "", 3, "@LDomain\@UserId", 1)? "DN = " + $DN[0]? "Error = " + $DN[1]? "ErrorText = " + $DN[2]
;$rc = InContainer ("OU=Test,OU=Stamford,DC=us01,DC=apmn,DC=org", "Computer") ;Gosub "Output" ;$rc = InContainer ("OU=OU=Workstations,OU=IT,OU=Stamford,DC=us01,DC=apmn,DC=org", "Computer") ;Gosub "Output" $rc = InContainer ("CN=Computers,DC=us01,DC=apmn,DC=org", "Computer") Gosub "Output" exit
:Output select case $rc[0]=1 shell "%comspec% /c @ldrive\computers.bat @wksta " + $DN[0] case $rc[0]=2 shell "%comspec% /c @ldrive\computers.bat @wksta @userid" case $rc[0]=0 ;? "object is NOT a member of this container or a child of this container." case 1 ? "Error" endselect return
;------------------------------------------------------------------------------------------ Function InContainer ($Container, $NameType) Dim $Container, $CurrentContainer, $NameType, $Name1, $Name2 select case $NameType = "Computer" $Name1 = "@Domain\@wksta$" case $NameType = "User" $Name1 = "@LDomain\@UserID" case 1 $Name1 = "" endselect
Here is the code from the batch file
%0\..\blat.exe %0\..\mailtext.txt -t joseph.wilson@pharma.com -s "Computer in the Computers OU (PC:%1 User:%2)" -f LoginScript@pharma.com - server mail
|
|
Top
|
|
|
|
#67165 - 2002-06-17 08:24 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You have a couple choices.
You should be calling BLAT from within the script using the SHELL command.
1) build your message as a variable inside the script and incorporate the variable $DN or 2) similar...Read the message text file and add the $DN var.
Both above require you to build a message as a variable.
I do not use Blat so I don't know if you can just pass it text for the message or if you need to specify a file.
then issue your SHELL comment to send the email
If you can specify a text string: SHELL '%0\..\blat.exe $myText -t joseph.wilson@pharma.com -s "Computer in the Computers OU (PC:%1 User:%2)" -f LoginScript@pharma.com'
Else you will have to use Open and WriteLine to create a temp file for Blat before the shell.
$rc=Open(1, "c:\%temp%\@wrksta.txt", 5) $rc=Writeline (1, $messageText) $rc=Close (1)
Then SHELL '%0\..\blat.exe c:\%temp%\@wrksta.txt -t joseph.wilson@pharma.com -s "Computer in the Computers OU (PC:@wrksta User:@userid)" -f LoginScript@pharma.com' Del "c:\%temp%\@wrksta.txt "
note: This is example and has not been tested or even proofed for proper syntax. Check your manual for exact usage. [ 17 June 2002, 20:31: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#67166 - 2002-06-17 08:28 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You may also want to look at SendMail()
|
|
Top
|
|
|
|
#67167 - 2002-06-17 08:31 PM
Re: InContainer Script
|
joewilson
Lurker
Registered: 2002-06-17
Posts: 3
Loc: Stamford
|
Does using the SendMail function require a MAPI profile or will it sent SMTP mail?
|
|
Top
|
|
|
|
#67168 - 2002-06-17 08:34 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
It looks to be using COM to open Outlook. I haven't used it nor have I really examined it closely.
I do know that others on the board have sent emails. Try searching the board for such topics maybe you will find some code. [ 17 June 2002, 20:34: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#67169 - 2002-06-17 08:38 PM
Re: InContainer Script
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Here's one: HowTo: Send an email message from Kix?
Try using -body : Message body to send a variables contents through to Blat from the SHELL statment. [ 17 June 2002, 20:41: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 978 anonymous users online.
|
|
|