Page 1 of 1 1
Topic Options
#71212 - 2002-01-08 10:17 PM Various ADSI Kix scripts.
davidrgeorge Offline
Lurker

Registered: 2002-01-08
Posts: 2
I use kix for several admin functions above just logon scripts. It's like the best of both worlds between VB and batch files.
Here are some functions that I have created:

function UserInGroup
;This will query a domain (or workstation) group to determine if the specified user name is a member.
;Returns 1 if the user is a member
;Returns 0 if the user is not a member
($UserName,$GroupName,$DomainName)
$UserInGroup = 0
$user=GetObject("WinNT://$DomainName/$UserName")
for each $prop in $user.groups
if $GroupName = $prop.name
$UserInGroup = 1
endif
next
endfunction

function ModUserAccount
;This will modify a domain (or workstation) user account.
;The value used for Property must be exact and must be one of the following:
; Description
; FullName
; HomeDirDrive (Letter for drive mapping)
; HomeDirectory
; LoginScript
; Profile (user profile directory)
;Enter the value just as you would using User Manager (or the W2K equivalent)
;Returns 1 for a successful update
;Returns 0 if it was not successful
($DomainName,$UserName,$Property,$Value)
$UserProperties = 0
$Usr=GetObject("WinNT://$DomainName/$UserName,user")
Select
Case $Property="Description"
$Usr.Description=$Value
Case $Property="FullName"
$Usr.FullName=$Value
Case $Property="HomeDirDrive" ;Letter for drive mapping
$Usr.HomeDirDrive=Ucase($Value)
Case $Property="HomeDirectory"
$Usr.HomeDirectory=$Value
Case $Property="LoginScript"
$Usr.LoginScript=$Value
Case $Property="Profile"
$Usr.Profile=$Value
EndSelect
$ChangeUser=$Usr.SetInfo
? $Usr ?
if $Usr <> ""
$ModUserAccount = 1
endif
endfunction

function UserRename
;This will rename a user account
;Returns 0 for nonsuccessful and 1 for a successful rename
;If you have to do this on a large scale for several users at once, let me know, and I'll email you the full code to rename the accounts, Home Directories, and User Profile directories also. davidrgeorge@yahoo.com
($OldUserName,$NewUserName,$DomainName)
$UserRename = 0
$Dmn=GetObject("WinNT://$DomainName")
$Usr=GetObject("WinNT://$DomainName/$OldUserName,user")
$DoRename=$Dmn.MoveHere($Usr.AdsPath,$NewUserName)
if $DoRename <> ""
$UserRename = 1
endif
endfunction

[ 17 January 2002: Message edited by: davidrgeorge ]

Top
#71213 - 2002-01-08 10:55 PM Re: Various ADSI Kix scripts.
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi david,

Welcome to the board!

Nice of you to share your UDF, I'm sure it can help others.

But... ah, the famous but ... could you take a look at the other postings on this forum and edit your post so that the properties of the function are clear?

You might want to describe the function with an explanation of the parameters and what it returns.

If you'd like some help with it, you know were to find me

_________________________
The Code is out there

Top
#71214 - 2002-10-26 04:07 AM Re: Various ADSI Kix scripts.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
needs a bomb...
or just pop.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1183 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.054 seconds in which 0.026 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