Hal
(Fresh Scripter)
2010-09-16 09:31 AM
Logon Skript not work correctly

Hi,

i have a write a little logon script but it wont work very well
this mean somtime it work sometime not.
on target machines when i look in the eventviewer i see
ERROR 2221 usergetinfo
ERROR 2221 GetPrimaryGroup
ERROR 2221 UserlocalGroups
ERROR 1332 GetlookupSID failed

i search in the forum but not found what help

here is my skript
hope someone can help
we have two windows 2003 dc
kixtart version is 4.61

many thanks
Hal
 Code:
;-----------------------------------------------------------
; Drucker

If InGroup("mydomain\G-Technik")
If AddPrinterConnection("\\printserver\Technik_Kyocera") <> 0
endif
EndIf



If InGroup("mydomain\G-GL")
If AddPrinterConnection("\\printserver\GF_Canon") <> 0
EndIf
EndIf

If InGroup("mydomain\G-Verwaltung") or @WkSta = "DRUCKER_TEST"
If AddPrinterConnection("\\printserver\Orga_Brother") <> 0
EndIf
If AddPrinterConnection("\\printserver\Orga_Canon") <> 0
EndIf
EndIf

If InGroup("mydomain\G-Vertrieb") or @WkSta = "DRUCKER_TEST"
If AddPrinterConnection("\\printserver\Vertrieb_Canon") <> 0
EndIf
EndIf
;-----------------------------------------------------------
; Standard-Verzeichnise

Use B: "\\mydomain\dfs\büroorga"
Use U: "\\mydomain\dfs\user\" + @USERID
Use M: "\\mydomain\dfs\büro"

;-----------------------------------------------------------
; Mitarbeiter-Gruppe

If InGroup("mydomain\G-Mitarbeiter")
	Use P: "\\mydomain\dfs\projekte"
EndIf


;-----------------------------------------------------------
; Auszubildende-Gruppe

If InGroup("mydomain\G-Auszubildende")
	Use P: "\\mydomain\dfs\projekte"
EndIf


;-----------------------------------------------------------
; Praktikanten-Gruppe

If InGroup("mydomain\G-Praktikanten")
	Use K: "\\mydomain\dfs\Praktikanten"
EndIf


;-----------------------------------------------------------
; Vertrieb-Gruppe

If InGroup("mydomain\G-Vertrieb")
	Use W: "\\mydomain\dfs\vertrieb"
EndIf


;-----------------------------------------------------------
; Verwaltung-Verzeichnis

If InGroup("mydomain\G-Verwaltung")
	Use V: "\\mydomain\verwaltung\verwaltung"
	Use N: "\\mydomain\dfs\marketing"
EndIf


;-----------------------------------------------------------
; VerwaltungVertrieb-Verzeichnis

If InGroup("mydomain\G-Verwaltung") Or InGroup("mydomain\G-Vertrieb")
	Use L: "\\mydomain\dfs\verwaltungvertrieb"
EndIf


;-----------------------------------------------------------
; Technik-Gruppe

If InGroup("mydomain\G-Technik")
;	Use I: "\\mydomain\dfs\install"
	Use T: "\\mydomain\dfs\technik"
EndIf
;-----------------------------------------------------------
; GL-Verzeichnis

If InGroup("mydomain\G-GL")
	Use G: "\\mydomain\verwaltung\gl"
	Use N: "\\mydomain\dfs\marketing"
EndIf

;-----------------------------------------------------------
; Fibu-Verzeichnis

If InGroup("mydomain\G-Fibu")
	Use S: "\\mydomain\verwaltung\fibu"
Endif


LonkeroAdministrator
(KiX Master Guru)
2010-09-17 08:59 PM
Re: Logon Skript not work correctly

you say you can see these events in the eventlogs but what is the source?
do they appear how often?


Hal
(Fresh Scripter)
2010-09-20 02:12 PM
Re: Logon Skript not work correctly

the source is KIXTART.

they appear 14 times during logon,
but the script did not start.
on some pc the script starts and quit before the If InGroup check.

when i run the skript manualy everythink is all right.

What and why can this be???


Mart
(KiX Supporter)
2010-09-20 04:17 PM
Re: Logon Skript not work correctly

Ok. I cleaned up the code a bit and stuffed loads of error checking in it.
What happens if you run it like this?

 Code:
; Drucker
If InGroup("mydomain\G-Technik")
	? "Deleting \\printserver\Technik_Kyocera"
	$rc = DelPrinterConnection("\\printserver\Technik_Kyocera")
	? @ERROR
	? @SERROR
	?"Mapping \\printserver\Technik_Kyocera"
	$rc = AddPrinterConnection("\\printserver\Technik_Kyocera")
	? @ERROR
	? @SERROR
EndIf

If InGroup("mydomain\G-GL")
	? "Deleting \\printserver\GF_Canon"
	$rc = DelPrinterConnection("\\printserver\GF_Canon")
	? @ERROR
	? @SERROR
	?"Mapping \\printserver\GF_Canon"
	$rc = AddPrinterConnection("\\printserver\GF_Canon")
	? @ERROR
	? @SERROR
EndIf

If InGroup("mydomain\G-Verwaltung") Or @WkSta = "DRUCKER_TEST"
	? "Deleting \\printserver\Orga_Brother"
	$rc = DelPrinterConnection("\\printserver\Orga_Brother")
	? @ERROR
	? @SERROR
	?"Mapping \\printserver\Orga_Brother"
	$rc = AddPrinterConnection("\\printserver\Orga_Brother")
	? @ERROR
	? @SERROR
	?"Mapping \\printserver\Orga_Canon"
	$rc = AddPrinterConnection("\\printserver\Orga_Canon")
	? @ERROR
	? @SERROR
EndIf

If InGroup("mydomain\G-Vertrieb") Or @WkSta = "DRUCKER_TEST"
	? "Deleting \\printserver\Vertrieb_Canon"
	$rc = DelPrinterConnection("\\printserver\Vertrieb_Canon")
	? @ERROR
	? @SERROR
	?"Mapping \\printserver\Vertrieb_Canon"
	$rc = AddPrinterConnection("\\printserver\Vertrieb_Canon")
	? @ERROR
	? @SERROR
EndIf

; Standard-Verzeichnise
Use B: /delete /persistent
? "Deleting B drive"
? @ERROR
? @SERROR
Use B: "\\mydomain\dfs\büroorga"
?"Mapping B drive."
? @ERROR
? @SERROR

Use U: /delete /persistent
? "Deleting U drive"
? @ERROR
? @SERROR
Use U: "\\mydomain\dfs\user\" + @USERID
?"Mapping U drive."
? @ERROR
? @SERROR

Use M: /delete /persistent
? "Deleting M drive"
? @ERROR
? @SERROR
Use M: "\\mydomain\dfs\büro"
?"Mapping M drive."
? @ERROR
? @SERROR

; Mitarbeiter-Gruppe
If InGroup("mydomain\G-Mitarbeiter")
	Use P: /delete /persistent
	? "Deleting P drive"
	? @ERROR
	? @SERROR
	Use P: "\\mydomain\dfs\projekte"
	?"Mapping P drive."
	? @ERROR
	? @SERROR
EndIf

; Auszubildende-Gruppe
If InGroup("mydomain\G-Auszubildende")
	Use P: /delete /persistent
	? "Deleting P drive"
	? @ERROR
	? @SERROR
	Use P: "\\mydomain\dfs\projekte"
	?"Mapping P drive."
	? @ERROR
	? @SERROR
EndIf

; Praktikanten-Gruppe
If InGroup("mydomain\G-Praktikanten")
	Use K: /delete /persistent
	? "Deleting K drive"
	? @ERROR
	? @SERROR
	Use K: "\\mydomain\dfs\Praktikanten"
	?"Mapping K drive."
	? @ERROR
	? @SERROR
EndIf

; Vertrieb-Gruppe
If InGroup("mydomain\G-Vertrieb")
	Use K: /delete /persistent
	? "Deleting K drive"
	? @ERROR
	? @SERROR
	Use W: "\\mydomain\dfs\vertrieb"
	?"Mapping W drive."
	? @ERROR
	? @SERROR
EndIf

; Verwaltung-Verzeichnis
If InGroup("mydomain\G-Verwaltung")
	Use V: /delete /persistent
	? "Deleting V drive"
	? @ERROR
	? @SERROR
	Use V: "\\mydomain\verwaltung\verwaltung"
	?"Mapping V drive."
	? @ERROR
	? @SERROR
	Use N: /delete /persistent
	? "Deleting N drive"
	? @ERROR
	? @SERROR
	Use N: "\\mydomain\dfs\marketing"
	?"Mapping N drive."
	? @ERROR
	? @SERROR
EndIf

; VerwaltungVertrieb-Verzeichnis
If InGroup("mydomain\G-Verwaltung") Or InGroup("mydomain\G-Vertrieb")
	Use L: /delete /persistent
	? "Deleting L drive"
	? @ERROR
	? @SERROR
	Use L: "\\mydomain\dfs\verwaltungvertrieb"
	?"Mapping L drive."
	? @ERROR
	? @SERROR
EndIf

; Technik-Gruppe
If InGroup("mydomain\G-Technik")
	;Use I: /delete /persistent
	;Use I: "\\mydomain\dfs\install"
	Use T: /delete /persistent
	? "Deleting T drive"
	? @ERROR
	? @SERROR
	Use T: "\\mydomain\dfs\technik"
	?"Mapping T drive."
	? @ERROR
	? @SERROR
EndIf

; GL-Verzeichnis
If InGroup("mydomain\G-GL")
	Use G: /delete /persistent
	? "Deleting G drive"
	? @ERROR
	? @SERROR
	Use G: "\\mydomain\verwaltung\gl"
	?"Mapping G drive."
	? @ERROR
	? @SERROR
	Use N: /delete /persistent
	? "Deleting N drive"
	? @ERROR
	? @SERROR
	Use N: "\\mydomain\dfs\marketing"
	?"Mapping N drive."
	? @ERROR
	? @SERROR
EndIf

; Fibu-Verzeichnis
If InGroup("mydomain\G-Fibu")
	Use S: /delete /persistent
	? "Deleting S drive"
	? @ERROR
	? @SERROR
	Use S: "\\mydomain\verwaltung\fibu"
	?"Mapping S drive."
	? @ERROR
	? @SERROR
EndIf


Hal
(Fresh Scripter)
2010-09-21 10:48 AM
Re: Logon Skript not work correctly

Hello,

Thank you Mart!
i try it but still get 13 errors
11x Error 2221 UserGetInfo
Error 1332 GetPG
Error 1332 GetPrimaryGroup

the mapping of the drive seems to be working.
but i don´t get any printer even when i disable the in ingroup funktion for the printer.

when i run it manualy it works without any failure in the eventlog.
Really Strange for me.

Regards,
Hal


Hal
(Fresh Scripter)
2010-09-21 11:03 AM
Re: Logon Skript not work correctly

one question
what mean $rc or what it does??


Mart
(KiX Supporter)
2010-09-21 11:12 AM
Re: Logon Skript not work correctly

Error 1332 means ERROR_NONE_MAPPED 1332 (0x534) No mapping between account names and security IDs was done.

Sounds familiar we someone that had the same issues some time ago. There was also a fix for this if I recall correctly. I did not find the post. I’ll do some searching and If I find I’ll let you know.


BradV
(Seasoned Scripter)
2010-09-21 12:24 PM
Re: Logon Skript not work correctly

I think this might be the post Mart was thinking of:

1332 error


Glenn BarnasAdministrator
(KiX Supporter)
2010-09-21 12:49 PM
Re: Logon Skript not work correctly

 Originally Posted By: Hal
one question
what mean $rc or what it does??
$Rc catches the "Return Code".

Most functions return values. Some function return codes mimic or mirror the error status, making them somewhat redundant if things go well. Thus, if you call a function and then test the @ERROR code, you can usually ignore the return code. If you don't "catch" it by putting it into a variable, it just "falls out" of your code and you wind up with random text (mostly numbers) on your screen.

This is described in more detail in the FAQ section.

Glenn


Mart
(KiX Supporter)
2010-09-21 01:16 PM
Re: Logon Skript not work correctly

 Originally Posted By: BradV
I think this might be the post Mart was thinking of:

1332 error


Yes. That’s it.


Hal
(Fresh Scripter)
2010-09-21 03:33 PM
Re: Logon Skript not work correctly

thanks
but why it is working manualy???
and not at the logon???


Mart
(KiX Supporter)
2010-09-21 04:25 PM
Re: Logon Skript not work correctly

Could be a timing issue. I do not know your setup or network history so it is a bit difficult to see why this is happening.
Did you check out the link Brad posted and the link in that thread?


Hal
(Fresh Scripter)
2010-09-21 04:44 PM
Re: Logon Skript not work correctly

yes i check the link but i cant find the sid history on my ad

Hal
(Fresh Scripter)
2010-09-21 05:31 PM
Re: Logon Skript not work correctly

i have looked now with different tools
ldp.exe, whoiam, José,..
but i cant find the SID history