please give me a hand, anything about this topic is welcome.
thanks
6 15922
please give me a hand, anything about this topic is welcome.
thanks
- win32net.NetGroupAddMembers(server, group, level, members_data)
This is purposefully cryptic. You'll need to study the Win32 package and ensure that you know what you are doing with Windows sys/admin.
The thing is: I don't want to tell you something and have you break you machine.
- win32net.NetGroupAddMembers(server, group, level, members_data)
This is purposefully cryptic. You'll need to study the Win32 package and ensure that you know what you are doing with Windows sys/admin.
The thing is: I don't want to tell you something and have you break you machine.
I can provide the missing information given a little background and more details of your environment. i.e. local machine vs domain, NT variant, etc.
I want to create user in win2k server, win 2k professional and win XP. if the user has already exists, I also need to be able to check and change its password.
now i want to change the IP related settings, could you please give me a function list or code sample?
thanks a lot
I want to create user in win2k server, win 2k professional and win XP. if the user has already exists, I also need to be able to check and change its password.
now i want to change the IP related settings, could you please give me a function list or code sample?
thanks a lot
From Python Programming on Win32 By Mark Hammond and Andy Robinson © 2000 - # BatchUserCreate.py
-
#
-
# A sample administrative script to perform a batch
-
# creation of many users.
-
-
# Input to this program is a text file with one user per
-
# line. Each line contains the new username and the
-
# user's full name.
-
-
# Creates the new user, and a new share on the server
-
# for the user. The new share is secure, and can only
-
# be accessed by the new user.
-
import win32security, win32net, win32file, win32api
-
import win32netcon, ntsecuritycon
-
import os, sys, string
-
-
# The name of the server to use to create the user.
-
serverName = None
-
-
# The logic for naming the home_drive assumes we have
-
# a server name. If we dont, get the current machine name.
-
if serverName is None:
-
serverName = "\\\\" + win32api.GetComputerName()
-
-
# The root of each users personal directory.
-
# This is a local reference to the directory where each
-
# personal directory is created.
-
homeRoot = "C:\\Users"
-
-
def CreateUserAndShare(userName, fullName):
-
homeDir = "%s\\%s" % (serverName, userName)
-
# Create user data in information level 3 (PyUSER_INFO_3) format.
-
userData = {}
-
userData['name'] = userName
-
userData['full_name'] = fullName
-
userData['password'] = userName
-
userData['flags'] = win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT
-
userData['priv'] = win32netcon.USER_PRIV_USER
-
userData['home_dir'] = homeDir
-
userData['home_dir_drive'] = "P:"
-
userData['primary_group_id'] = ntsecuritycon.DOMAIN_GROUP_RID_USERS
-
userData['password_expired'] = 1 # User must change password next logon.
-
-
# Create the user
-
win32net.NetUserAdd(serverName, 3, userData)
-
-
# Create the new directory, then the share
-
dirName = os.path.join(homeRoot, userName)
-
os.mkdir(dirName)
-
shareData = {}
-
shareData['netname'] = userName
-
shareData['type'] = win32netcon.STYPE_DISKTREE
-
shareData['path'] = dirName
-
shareData['max_uses'] = -1
-
# The security setting for the share.
-
sd = CreateUserSecurityDescriptor(userName)
-
shareData['security_descriptor'] = sd
-
# And finally create it.
-
win32net.NetShareAdd(serverName, 502, shareData)
-
-
# A utility function that creates an NT security object for a user.
-
def CreateUserSecurityDescriptor(userName):
-
sidUser = win32security.LookupAccountName(serverName, userName)[0]
-
sd = win32security.SECURITY_DESCRIPTOR()
-
-
# Create the "well known" SID for the administrators group
-
subAuths = ntsecuritycon.SECURITY_BUILTIN_DOMAIN_RID, \
-
ntsecuritycon.DOMAIN_ALIAS_RID_ADMINS
-
sidAdmins = win32security.SID(ntsecuritycon.SECURITY_NT_AUTHORITY, subAuths)
-
-
# Now set the ACL, giving user and admin full access.
-
acl = win32security.ACL(128)
-
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
-
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidAdmins)
-
-
sd.SetSecurityDescriptorDacl(1, acl, 0)
-
return sd
-
-
# Debug helper to delete our test accounts and shares.
-
def DeleteUser(name):
-
try: win32net.NetUserDel(serverName, name)
-
except win32net.error: pass
-
-
try: win32net.NetShareDel(serverName, name)
-
except win32net.error: pass
-
-
try: os.rmdir(os.path.join(homeRoot, name))
-
except os.error: pass
-
-
if __name__=='__main__':
-
import fileinput # Helper for reading files line by line
-
if len(sys.argv)<2:
-
print "You must specify an options file"
-
sys.exit(1)
-
if sys.argv[1]=="-delete":
-
for line in fileinput.input(sys.argv[2:]):
-
DeleteUser(string.split(line,",")[0])
-
else:
-
for line in fileinput.input(sys.argv[1:]):
-
userName, fullName = string.split(string.strip(line), ",")
-
CreateUserAndShare(userName, fullName)
-
print "Created", userName
-
For further support on this, you'll need to buy the book.
thanks. very useful for my task.
thanks. very useful for my task.
You are welcome. I'm glad to know that you received the material.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Isal |
last post by:
hi all,
i'm new to python and i'm trying to build a python extension on win98,
written in c++, with cygwin.
but i keep having the same error message, and i didnt't find much
resources on the web...
|
by: Bernhard Mulder |
last post by:
I am using Python on Itanium Windows 64 (Server 2003) with a Win32 version.
Is there a native version available or planned? Are testers needed for
this platform?
Windows 64 is a bit unusual in...
|
by: Ryan Smith |
last post by:
Hello All,
I am new to the list and python community as well. I was wondering if anyone
knows of any good python books emphasizing Windows 2000? I am a network
engineer in an Active Directory...
|
by: Skip Montanaro |
last post by:
I'd like to package up my typing watcher script in a bundled form (no
separate Python install required) for use on Windows. (Un)fortunately, I
don't have access to a Windows computer. Do any of...
|
by: Michael Kearns |
last post by:
I've been using python to write a simple 'launcher' for one of our Java
applications for quite a while now. I recently updated it to use python
2.4, and all seemed well.
Today, one of my...
|
by: abcd |
last post by:
I am using Python to create a process on another computer. Both
computers are on the same domain with admin privileges.
On computer B I have a batch script which starts a python script. From...
|
by: bhochstetler |
last post by:
I am needing to build python 2.5 on Windows XP x64 Windows Server 2003
sp1 Platform SDK and am not finding anything documented on the process
to use. Has anyone had any success with this? If so has...
|
by: p.lavarre |
last post by:
Let's suppose you get Python for Vista Windows today from
http://www.python.org/download/.
Should you then conclude that the tests:
if platform.system() in ('Windows', 'Microsoft'):
if not...
|
by: Joshua Kugler |
last post by:
We've recently been doing some profiling on a project of ours. It runs
quite fast on Linux but *really* bogs down on Windows 2003. We initially
thought it was the simplejson libraries (we don't...
|
by: Theo v. Werkhoven |
last post by:
hi,
In this code I read out an instrument during a user determined period,
and save the relative time of the sample (since the start of the test)
and the readback value in a csv file.
#v+...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |