[python-win32] need help in creating a username generator
Fri, 4 Apr 2003 15:42:26 -0800
Thanks... I'll give it a try and post my results back here.
From: d.w. harks [mailto:firstname.lastname@example.org]
Sent: Friday, April 04, 2003 12:57 PM
Subject: Re: [python-win32] need help in creating a username generator
I do this, but not in nearly so flexible a manner. Guess I'm lazy. :-)
I just have the function generate three different possible usernames,
based on the user's first, middle and last names, and append the results
to a list. I've never had the situation come up where I can't get a =
username...but I work for a small university, and we only have about =
Then, it checks each one against AD, and the first one that is not =
taken gets assigned to the user.
I could see this working with a list of function references which could =
selected at runtime from a pool of available username-generation
funcList =3D [ stuOne, stuTwo, ...] # generate this with your setup =
optionList =3D 
for func in funcList:
Just a thought.
Brian Jarrett said:
> Hello all.
> I'm new to Python and I've been working on some scripts to automate =
> creation of user accounts on our network. I work in a school =
> I want the school secretaries to use a webpage to create student user
> accounts and I will have the administrations staff create employee =
> accounts and email boxes.
> What I want to do is create some sort of object or function that would
> take a variable number of "rules" and apply them to information =
> (firstname, lastname, middle initial, graduation year) to come up with =
> username for the individual. If the first username is already used, =
> it would try applying the next "rule" until it came up with a unique =
> Since I have two classes of users (Employees and Students) I will =
> two separate sets of rules.
> I already have code that checks my Active Directory to see if a =
> has not been used. I just need something to generate the username to
> Of course I could hardcode how I'd want to slice up first and last =
> etc, to get a username, but I thought I'd make it more flexible and =
> release it for others to use if they wanted.
> The rules I'd be using would be something like:
> Try first initial + last name
> Try first initial + middle initial + last name
> Try first initial + last name + last 2 digits of grad year
> Try first initial + middle initial + last name + last 2 digits of grad
> Try first two letters of first name + last name + last 2 digits of =
> Any ideas on how to do this would be appreciated. Mainly I'm =
> with making the rules persistent but easily changed and flexible =
> add/remove data to use and how to specify the use of said data.
> Brian Jarrett
> Network Administrator
> Garfield County School District 16
> Python-win32 mailing list
d.w. harks <email@example.com> http://dwblog.psys.org
Python-win32 mailing list