Page 1 of 1 1
Topic Options
#122072 - 2004-07-02 11:22 AM set first name, last name as domain user?
MathiasS Offline
Lurker

Registered: 2004-06-28
Posts: 2
Hi,
we create the users in our domain with a script.
So we tried to get the users first and lastname on first login if the firstname is not set.
Following script works fine, with one problem: the user needs admin rights.

Of course all users are domain users.
Is there any solution for this problem?

My code:
Code:
 

Dim $Filter[0]
$Filter[0]="user"
$ou = GetObject("LDAP://OU=schueler,DC=schule,DC=hh")
For Each $User In $ou
$ou.Filter = $Filter
If Ucase($User.sAMAccountName) == Ucase(@USERID)
$Found = 1
If Len($user.firstname) < 1
? "there is no firstname"
@CRLF
@CRLF
:firstname
? "firstname?"
@CRLF
Gets $NewFirstname
@CRLF
If NOT $NewFirstname
? "give firstname!"
@CRLF
? "q to quit"
? "any key - new try"
Get $x
If $x <> q

GoTo firstname
Else
Exit
EndIf
EndIf
:lastname
? "lastname?"
@CRLF
Gets $NewLastName
@CRLF
If NOT $NewLastname
? "give lastname!"
@CRLF
? "q to quit"
? "any key - new try"
Get $x
If $x <> q

GoTo lastname
Else
Exit
EndIf
EndIf
$user.firstname = $NewFirstname
$User.lastname = $NewLastName
If $User.SetInfo = 0
? "succeeds"
Else
? "error:" + @SERROR
EndIf
Else
? "there is already a firstname."
EndIf
EndIf
Next

If NOT $Found
? "User Not Found !"
Exit
EndIf



thanks for any help
Mathias

Top
#122073 - 2004-07-02 02:25 PM Re: set first name, last name as domain user?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Do NOT use GOTO, especially to jump into the middle of an IF condition.
Always provide a parameter to EXIT. It is not as optional as the manual suggests.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122074 - 2004-07-02 02:33 PM Re: set first name, last name as domain user?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
write the infermation to a log file, and run a admin script that reads this information and makes the ADO changes for the users.


Top
#122075 - 2004-07-02 02:46 PM Re: set first name, last name as domain user?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
One cannot expect users to enter information correctly. That should be done by an admin.

Picking apart your code a bit...

KiX is not case sensitive so I wonder why you force UCASE and then use a case sensitive ==?
Ucase($User.sAMAccountName) == Ucase(@USERID)

Rather that loop through all the users in a FOR loop, translate the name with the TranslateName() UDF, and then use the DN in a direct LDAP operation.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122076 - 2004-07-02 04:01 PM Re: set first name, last name as domain user?
MathiasS Offline
Lurker

Registered: 2004-06-28
Posts: 2
thank you

@Les:
Ok. There are errors from me and things I picked from others without understanding or checking because a three weeks ago I've never heard about kix...
I will change these parts.

@Bryce:
Thats the idea I've missed!
Probably the only solution.


Top
#122077 - 2004-07-02 04:57 PM Re: set first name, last name as domain user?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
use something as simple as this to write the information to a log file.

Code:

$logfile = "g:\kix\sandbox\username.ini"

if not readprofilestring($logfile,"Username",@userid)
$Firstname = prompt("What is the spelling of your Firstname?"+@crlf)
$lastname = prompt("What is the spelling of your Lastname?"+@crlf)
$ = writeprofilestring($logfile,"Username",@userid,$firstname+","+$lastname)
endif

function prompt($question)
? $question+": "
gets $prompt
endfunction




Top
Page 1 of 1 1


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

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.103 seconds in which 0.073 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