Page 1 of 1 1
Topic Options
#190551 - 2008-11-11 03:34 PM KiX and ADSI
Kev147 Offline
Just in Town

Registered: 2008-11-10
Posts: 1
I have tried various UDf's and can't quite get what I am after, can anyone assist? I want the script to do something like below:

If @MAXPWAGE=30
$ = MessageBox("Is this your PC?", "PC Owner", 4160)
If Yes is selected
Search AD for OU that current user resides within
Display OU path of User object
$ = MessageBox("Is OU path Correct?", "User OU Path", 4160)
If Yes is selected
Search AD for OU that the local computer resides within
Move Computer Object to the OU the User is in, but instead of "Users" OU, it should be "Computers" OU
Else
Message("Call the Helpdesk", "User OU Path Incorrect")
EndIf
EndIf
EndIf

Top
#190558 - 2008-11-12 07:10 PM Re: KiX and ADSI [Re: Kev147]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11627
Loc: CA
Well a normal user shouldn't really be able to move their PC to another OU like that. Not sure their is specific pre-written code to do exactly as you want either. Might have to write some of that yourself, but wait around and maybe one of the other guys may have a solution.
Top
#190560 - 2008-11-13 09:52 AM Re: KiX and ADSI [Re: Kev147]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is a sample script which displays the information that you are interested in, then gets the computer and user objects from AD and displays a bit of data from them as well.

Now you just need to add the code to display the prompts and move the computer to the right OU, though I agree with the Doc that allowing end users that privilege is not a good thing.
 Code:
Break ON

$objSysInfo = CreateObject("ADSystemInfo") 
$strComputerDN = $objSysInfo.computerName 
$strUserDN = $objSysInfo.userName 

$strUserOU=Split($strUserDN,"OU=")
$strUserOU[0]=""
$strUserOU=Join($strUserOU,"OU=")

$strComputerOU=Split($strComputerDN,"OU=")
$strComputerOU[0]=""
$strComputerOU=Join($strComputerOU,"OU=")


"Information from ADSystemInfo"+@CRLF
"-----------------------------"+@CRLF
"           User DN: "+$strUserDN+@CRLF
"    User container: "+$strUserOU+@CRLF
"       Computer DN: "+$strComputerDN+@CRLF
"Computer container: "+$strComputerOU+@CRLF
@CRLF

"Information from AD User & Computer objects"+@CRLF
"-------------------------------------------"+@CRLF
$objComputer = GetObject("LDAP://" + $strComputerDN)
$objUser = GetObject("LDAP://" + $strUserDN)

"           User cn: "+$objUser.cn+@CRLF
"         User mail: "+$objUser.mail+@CRLF
"       Computer OS: "+$objComputer.operatingSystem+@CRLF

Exit 0

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
0 registered and 405 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.056 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

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