Page 1 of 1 1
Topic Options
#183350 - 2007-12-06 05:09 PM AD help
MikeMarten Offline
Fresh Scripter

Registered: 2007-12-06
Posts: 8
 Code:
$username = "desktest"


$userhome = TranslateName (3, "", 3, "@LDomain\$username", 1)
$userinfo = GetObject("LDAP://" + $userhome[0])


$userinfo.profilePath = ""
$userinfo.SetInfo


; TranslateName function authored by Howard A. Bullock
Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText
$Error = 0
$ErrorText = ""
$ReturnName = ""
$NameTranslate = CreateObject ("NameTranslate")
$Error = @error
$ErrorText = @serror
If $Error = 0
 $NameTranslate.Init ($InitType, $BindName)
 $Error = @error
 $ErrorText = @serror
 If $Error = 0
  $NameTranslate.Set ($LookupNameType, $LookupName)
  $Error = @error
  $ErrorText = @serror
  If $Error = 0
   $ReturnName = $NameTranslate.Get($ReturnNameType)
   $Error = @error
   $ErrorText = @serror
  EndIf
 EndIf
EndIf
$TranslateName = $ReturnName, $Error, $ErrorText
EndFunction


I am trying to delete the profile path. When I set the attribute to "" it does nothing. My question is if I set the attribute to " " is that the same thing? I really don't think so.

Any help in the right direction is appreciated.

Mike

Top
#183354 - 2007-12-06 05:43 PM Re: AD help [Re: MikeMarten]
MikeMarten Offline
Fresh Scripter

Registered: 2007-12-06
Posts: 8
OK got it its putEx for future ref. \:\)

Thanks to Howard A. Bullock for the Translate name function. ;\)


Edited by MikeMarten (2007-12-06 05:46 PM)

Top
#183355 - 2007-12-06 05:58 PM Re: AD help [Re: MikeMarten]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You answered your own question before I could respond. Could you post your working code so that others can have an example?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#183450 - 2007-12-10 01:57 AM Re: AD help [Re: Howard Bullock]
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Attempts to use the Put method to set attribute values to null or an empty string will cause an error. So PutEx has to be used instead.

http://support.microsoft.com/kb/260251

Top
#183562 - 2007-12-12 09:43 PM Re: AD help [Re: Howard Bullock]
MikeMarten Offline
Fresh Scripter

Registered: 2007-12-06
Posts: 8
Below is thee code that I used. I think a better way to see if the user has been migrated from a roaming profile yet would be to just run a query of the profilepath that is in AD and if it is not "" then continue on. I am going to work on that. \:\)

 Code:
;Checks to for touch file to see if we have already migrates user
	If Not Exist ("$TouchLoc\@USERIDroamdelete.tch")
			; Sets the username to the logged on user
				$username = @USERID		
				; Calls the Translate function on the userID to get the FQDN
				$userhome = TranslateName (3, "", 3, "@LDomain\$username", 1)
				;Binds to the Users Active Directory Object
				$userinfo = GetObject("LDAP://" + $userhome[0])
				
				
				;deletes the profile path in Active Directory
				$userinfo.putEX(1, "profilePath", "")
				;Executes the Query
				$userinfo.SetInfo
		;Writes the touch file 
		Open(3,"$TouchLoc\@USERIDroamdelete.tch",5)
		WriteLine (3,"PLEASE DO NOT DELETE THIS FILE")
		Close(3)
	EndIf

Top
#183565 - 2007-12-12 09:58 PM Re: AD help [Re: MikeMarten]
MikeMarten Offline
Fresh Scripter

Registered: 2007-12-06
Posts: 8
OK I was correct here is what I am going to go with (i think)

 Code:
; Sets the username to the logged on user
		$username = @USERID		
		; Calls the Translate function on the userID to get the FQDN
		$userhome = TranslateName (3, "", 3, "@LDomain\$username", 1)
		;Binds to the Users Active Directory Object
		$userinfo = GetObject("LDAP://" + $userhome[0])


		If Not $userinfo.profilepath = ""
		
			;deletes the profile path in Active Directory
			$userinfo.putEX(1, "profilePath", "")
			;Executes the Query
			$userinfo.SetInfo
			
		EndIf

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 1362 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.029 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