Page 1 of 1 1
Topic Options
#109246 - 2003-11-29 06:11 PM New functionality in Win32Admin3
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This post is the result of a request from Jose:

I have updated the Win32Admin.Zip with a new DLL and updated test scripts. A new script "LookupPrimaryGrp.kix" shows two ways how one can determine the primary group name of a user.

The first uses GetUserGroupFromRID to do a direct resolution of the RID to the name of the object identified by the RID. The RID was obtained using primary_group_id value retrieved via UserGetInfo.

The second, although it is longer, show additional methods and object that would be very useful in other applications. It uses, EnumTrustedDomains, VBS Dictionary Object (CreateObject("Scripting.Dictionary")), UserGetInfo, and LsaLookupSids.

I would be happy to answer any question about the methods of the DLL or the accompanying script.

http://home.comcast.net/~habullock/kix_solutions.htm
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#109247 - 2003-12-01 08:22 PM Re: New functionality in Win32Admin3
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Dear Howard:
Actually I am working-playing with the win32dll3.kix you sent me on friday. I cannot find the above reference of the LookupPrimaryGrp.kix in your page wich I would like to work with.
BTW...As I have decided to make full usage of your dll there is actully one thing I still do with WinNt object wich is GetUserList($DomainName). Do you think it could be possible to add this feature to your dll too? I am on an export script on Winnt server, I think you already told me that Win32Admin was compatible with 2000 server, Am i right?
Thanks again Howard.


_________________________
Life is fine.

Top
#109248 - 2003-12-01 08:36 PM Re: New functionality in Win32Admin3
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The scripting example is in the zip file with the latest DLL.

http://home.comcast.net/~habullock/Library/Win32Admin3.zip


I will look into adding what you need. Could you explain in a little more detail how you would like the method to work and what you would like to be returned?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#109249 - 2003-12-02 05:59 PM Re: New functionality in Win32Admin3
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Howard:
What I have made here is a script that dumps all the users properties to an excel sheet. What I tried to say above was that the only left appart from Win32Admin is how I get the users array (for UserGetInfo) to get the properties.
Code:
		;*************************************************************
; VARIABLES
;*************************************************************
$server="??" ;PDC server

;*************************************************************
; HOWARD DLL OBJECT
;*************************************************************
Break ON
$= SetOption("WrapAtEol","On")
? "KiXtart version = " @KIX
$Win32Admin = CreateObject("Win32Admin")
If VarTypeName($Win32Admin) <> "Object"
? "@serror"
EndIf

;*************************************************************
; CREATES EXCEL OBJECT
;*************************************************************
$oXL = CreateObject("EXCEL.application")
$oXL.Visible = 1 ; make Excel visible to the user
$rc=$oXL.Workbooks.Add ; add a new workbook
$array = "Name", "Group", "Full Name", "Profile", "Script Path", "Home dir drive", "Home dir", "Group", "Comment"
$oXL.Range("A1:I1").Value = $array ;add some columns

;*************************************************************
; GETS $USERS ARRAY WITH GetUserList FUNCTION (WINNT OBJECT)
;*************************************************************
$ = GetUserList(@DOMAIN)
$cant=Ubound($Users)

;*************************************************************
; GETS UserGetInfo
;*************************************************************
For $i=0 to $cant
$UserInfo = $Win32Admin.UserGetInfo("$server", $Users[$i])
If @error = 0
$keys = $UserInfo.keys
EndIf
For Each $key in $keys
$fullname = $UserInfo.full_name
$Value = $UserInfo.Get($key)
Select
Case $Key="name" AND $key <> ""
$name=$value
Case $Key="primary_group_id" AND $key <> ""
$Group = $Win32Admin.GetUserGroupFromRID("$server",$value)
Case $key="full_name" AND $key <> ""
$full_name=$value
Case $Key="profile" AND $key <> ""
$profile=$value
Case $key="script_path" AND $key <> ""
$script_path=$value
Case $key="home_dir_drive" AND $key <> ""
$home_dir_drive=$value
Case $key="home_dir" AND $key <> ""
$home_dir=$value
Case $Key="primary_group_id" AND $key <> ""
$Group = $Win32Admin.GetUserGroupFromRID("$server",$value)
Case $key="comment" AND $key <> ""
$comment=$value
EndSelect

;*************************************************************
; ADD VALUES TO EXCELL SHEET
;*************************************************************
$oXL.Cells(($i+2),1).Value = $name
$oXL.Cells(($i+2),2).Value = $Group
$oXL.Cells(($i+2),3).Value = $full_name
$oXL.Cells(($i+2),4).Value = $profile
$oXL.Cells(($i+2),5).Value = $script_path
$oXL.Cells(($i+2),6).Value = $home_dir_drive
$oXL.Cells(($i+2),7).Value = $home_dir
$oXL.Cells(($i+2),8).Value = $Group
$oXL.Cells(($i+2),9).Value = $comment
Next

;*************************************************************
; CLEAR VARS
;*************************************************************
$name=""
$Group=""
$full_name=""
$profile=""
$script_path=""
$home_dir_drive=""
$home_dir=""
$Group=""
$comment=""
Next

;*************************************************************
; ORDERS SHEET
;*************************************************************
$oXL.Range("A1:I1").Font.Bold = 1
$rc=$oXL.Range("A1:I1").EntireColumn.AutoFit
$oXL.UserControl = 1

;*************************************************************
; GetUserList FUNCTION GETS ARRAY OF ALL DOMAIN USERS
;*************************************************************
Function GetUserList ($DomainName)
Dim $count[5000]
;Create domain object
$Domain = GetObject("WinNT://" + $DomainName + ",domain")
;Set container object equal to domain object.
$Container = $Domain
;Iterates through EVERY object in the domain. Those
;objects that match the class are included in the array.
For Each $User In $Container
If $User.Class = "User"
$count[$x] = $User.Name
$x = $x + 1
EndIf
Next
;Resize the array appropriately
ReDim Preserve $count[$x - 1]
;Set $Users (global variable) equal to $count (local variable)
$Users = $count
;Object cleanup
$Domain = 0
$Container = 0
EndFunction




This has been very helpfull cause appart from backing up the database I saw lots of silly errors that I had.
Thanks Howard.
_________________________
Life is fine.

Top
#109250 - 2003-12-02 06:56 PM Re: New functionality in Win32Admin3
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Jose, you should be able to remove your "for each" loop and build a faster script by assigning the values directly to the spreadsheet cells. "primary_group_id" also seems to be used two times.

Code:

;*************************************************************
; ADD VALUES TO EXCELL SHEET
;*************************************************************
$oXL.Cells(($i+2),1).Value = $UserInfo.name
$oXL.Cells(($i+2),2).Value = $Win32Admin.GetUserGroupFromRID($server,$UserInfo.primary_group_id)
$oXL.Cells(($i+2),3).Value = $UserInfo.full_name
$oXL.Cells(($i+2),4).Value = $UserInfo.profile
$oXL.Cells(($i+2),5).Value = $UserInfo.script_path
$oXL.Cells(($i+2),6).Value = $UserInfo.home_dir_drive
$oXL.Cells(($i+2),7).Value = $UserInfo.home_dir
$oXL.Cells(($i+2),8).Value = $Win32Admin.GetUserGroupFromRID($server,$UserInfo.primary_group_id)
$oXL.Cells(($i+2),9).Value = $UserInfo.comment

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#109251 - 2003-12-03 07:34 PM Re: New functionality in Win32Admin3
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Removed the "for each". Thanks for the tips and the help given Howard. I let you know if I have any need regarding Win32Admin.
_________________________
Life is fine.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 781 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.052 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org