#17986 - 2002-02-26 05:57 PM
How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
I am going to be using ScriptLogic soon - a GUI based on the Kix32 language. We are currently using Firstname.Lastname as our username convention on our Win2000 domain. We are instituting a workstation naming convention that will include a department code + first initial + last name. Due to the convention, the last name will need to be truncated to 7 chars max.Do you know how I could extract this information and store it as a variable? The department code is easy - it's standard. But how do I capture the first initial and the first 7 characters of the last name from the Firstname.Lastname username? Or can this be captured from another macro within Kixstart?
|
|
Top
|
|
|
|
#17988 - 2002-02-26 06:25 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
Here's a start. This will get you the first 7 letters of the last name as long as you have their full name in User Manager for Domains. $LNAME = SUBSTR(@FULLNAME,1,7)
|
|
Top
|
|
|
|
#17989 - 2002-02-26 06:40 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
Thank you for the great suggestions, LLigetfa and MikeT. I will definitely have to check out ADSI via the adsi25.chm help file. And MikeT, thanks for the tip in using SUBSTR. Possibly I could use this to grab only the first letter of the full name, right? Then I could put the 2 values together to form the firstinitial+lastname convention I want. The purpose of this is to be able to automatically rename a few hundred 9x workstations instead of having to walk around personally. Of course, it will require a reboot to take effect, but that's not a problem.
|
|
Top
|
|
|
|
#17991 - 2002-02-26 07:59 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
It's gonna be a little tougher to get the first initial using the @FULLNAME and the SUBSTR command. What format do you use for your username (ex. First Initial, Last Name BSmith or Last Name First Initial SmithB).
|
|
Top
|
|
|
|
#17992 - 2002-02-26 08:33 PM
Re: How can I capture and trim the username?
|
Will Hetrick
Hey THIS is FUN
Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
|
Since your login names are currently firstname.lastname, Do a substr(@userid,1,1) to get the first letter of the first name. then do a while loop that looks for the "." while substr(@userid,$count,1) <> "." loop then when you find the period, add one more to substring and take the next 7 characters. substr(@userid,$count+1,7). This was just brainstorming. The code should be easy enough.
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!
|
|
Top
|
|
|
|
#17993 - 2002-02-26 08:37 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
MikeT, We are using Firstname.Lastname, ie Joe.Smith. Thanks!
|
|
Top
|
|
|
|
#17994 - 2002-02-26 08:50 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
$FINIT = SUBSTR(@USERID,1,1) Will give you the first initial and $FINITLNAME = "$FINIT" + "$LNAME" Will add them together.
|
|
Top
|
|
|
|
#17996 - 2002-02-26 10:00 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
Bryce, Thanks for your input! I think I had it worked out with a while - do loop, but a single expression is even better. Since I only want 7 letters of the last name, I think the following modification would work well. What do you think?$newname = substr(@userid,1,1)+substr(@userid,instr(@userid,".")+1,7)
|
|
Top
|
|
|
|
#17997 - 2002-02-27 06:50 PM
Re: How can I capture and trim the username?
|
Anonymous
Anonymous
Unregistered
|
Thanks again for all your input. I have implemented Bryce's solution and it is working great - very fast! I have also implemented a message box to allow the user to cancel the registry change should the need arise. Thanks!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 700 anonymous users online.
|
|
|