Page 1 of 1 1
Topic Options
#124979 - 2004-08-14 11:41 AM Adding users to domain from file script
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
A long subject I know - wasn't quite sure how to sum it up.
I'm new to the board and to KiX in general so a big "hi" goes out to all of you, have been browsing the forums and picking bits of code up here 'n' there.

I'm writing (or trying to write) a KiX script that does the following :
1) Takes the import.csv file (which is a special-format CSV)
2) Runs through it, carving the CSV into sections
3) Adds the domain OU (if it doesn't exist)
4) Adds the user to the domain UNLESS a duplicate user exists already, in that case, it should add a number to the end of the username (starting at '2' depending on how many duplicates).
5) It then sets passwords, group memberships and special attribs (such as change password @ next logon etc.)
6) Upon all of that being a success, it then creates the user home directory, assigns relevant permissions.
7) Displays a small 2-line status page giving the username
that was created, the password they were given and the path to their home directory.

Now, I've managed to do 1,2 and 3 by myself. But the duplicate checking I have is crude - all it does is see if a user with the same USERNAME exists, it doesn't add any numbers on or anything - but I'm sure I can figure that myself using the KiX manual and it's examples.

My problem is with the later steps - particularly 5 and 6.
The creating of username and associated password is fine (as I'm CURRENTLY shelling out using DSADD) so it does the entirity of '5' for me - but I'd rather use a pure KiX solution if possible (as in, it shells out to things ONLY when it must). I know you can add a user with KiX, but it's doing all that DSADD does that concerns me, particularly the 'user must change password at next login'.
If it can only part be done with KiX, then I'll stick with using DSADD.

While I am capable of creating a directory with KiX, it's the setting of permissions I'm unsure how to do. I'd rather not have to shell out to CACLS if I can avoid it.

One last thing - is it simple to script in KiX something that adds a domain user to a group (just 1 group) ? I'll look through the manual myself later and see but I'm unsure.

Top
#124980 - 2004-08-14 09:44 PM Re: Adding users to domain from file script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hello and welcome to the board.

Yes I think all (or at least almost all) can be done via KiXtart. Part of the folder/share/permissions issue also has to do with the size of your Network. There are replications issues involved in larger Networks that won't allow certain things to happen since the other servers won't know about the new addition right away.

What version of KiXtart are you using?
What Network NT4 or AD ?
Is this a School or something? How often do you need to add large groups of users?

Take a look at this posting for a little more information similar to this topic


GetSecurityDescriptor Problems
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=123844


ADSI can perform all the user/group/adds/moves/etc...
The Microsoft Script Center and our UDF forum should have all you need to accomplish these tasks. Converting VBS to KiXtart is pretty easy (remember thought that KiXtart can not access API calls)

Please take a look at the above mentioned articles and info and let us know when/where else you need assistance.

If stuck on a particular piece of code please post an example and we'll try to assist you in getting in working.

Top
#124981 - 2004-08-16 08:19 PM Re: Adding users to domain from file script
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
Thanks for the reply (sorry I'm a bit late).
As far as using KiXtart for all of it, I've decided to use MS's tools to directly manipulate file ACLs, add users. The rest of the script is just KiX.

I am using latest version of KiX, network is CURRENTLY NT4 but this will be changed shortly to AD (hence the script).
Yeah this is a school, the mass-import of users will occur every academic year w/o fail - aside from that, the script has little use.

Now, I've hit a problem - the file I am reading in has quotes and spaces in the usernames... neither of them are a problem as I know the structure of the file and am using SUBSTR/TRIM/LEFT/RIGHT to deal with those - however some of the usernames have dashes in them. I cannot seem to find a function that lets me search a string for a '-'. I have the code to remove the '-' (uses SPLIT). However, I just want to search the string, find if it has a '-' anywhere in it, if it does, use the code to remove it - if not, then do nothing to it and carry on.

So far the script itself works great, is just this little pest of '-'.

Any ideas on how I may accomplish this?

Top
#124982 - 2004-08-16 08:38 PM Re: Adding users to domain from file script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It sounds to me that you are not properly delimiting with quotes.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124983 - 2004-08-16 08:39 PM Re: Adding users to domain from file script
Arkane Offline
Getting the hang of it

Registered: 2004-08-14
Posts: 50
Loc: Bath, UK
The file format I've been given is standard for our schools' management system. Now the code I have removes the quotes happily - all I need to do is remove any '-' from the usernames as well. The other fields are mostly irrelevant.
Top
#124984 - 2004-08-16 08:54 PM Re: Adding users to domain from file script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Kix does NOT have a problem finding text with a hypen in it provided you properly delimit the search string!
Code:
Break On
$String = "'this-text','that-text','no hyphen text'"

$pos = InStr($String,'that-text')

$pos ?

get $

$StringArray = 'this-text','that-text','no hyphen text'

$pos = AScan($StringArray,'that-text')

$StringArray[$pos] ?


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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.059 seconds in which 0.029 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