No subject
karlos barlos
karlosbarlos at yahoo.com
Tue Apr 21 09:40:35 EDT 2009
ok sorry TIM
I just took some piece of code that ADDs users to AD
<CODE>
import win32com,win32com.client
def add_acct(location,account):
ad_obj=win32com.client.GetObject(location)
ad_user=ad_obj.Create('user','cn='+user['login'])
ad_user.Put('sAMAccountName',user['login'])
ad_user.Put('userPrincipalName',user['login']+'@email.address.com')
ad_user.Put('DisplayName',user['last']+' '+user['first']) #fullname
ad_user.Put('givenName',user['first'])
ad_user.Put('sn',user['last'])
ad_user.Put('description','regular account')
ad_user.Put('physicalDeliveryOfficeName','office 1')
ad_user.Put('HomeDirectory',r'\\server1\ '[:-1]+user['login'])
ad_user.Put('HomeDrive','H:')
ad_user.SetInfo();ad_user.GetInfo()
ad_user.LoginScript='login.bat'
ad_user.AccountDisabled=0
pas = raw_input("\nChoose PaSSword..:")
ad_user.setpassword(pas)
ad_user.Put('pwdLastSet',0) #-- force reset of password
ad_user.SetInfo()
very = raw_input("\nWhat OU To Place User...?:")
location=("LDAP://ou=%s,dc=shay,dc=com" % very)
name = raw_input("\nEnter The First Name...:")
last = raw_input("\nEnter The Last Name....:")
log = raw_input("\nEnter LOGON Name. at .......:")
user={'first':(name),'last':(last),'login':(log)}
add_acct(location,user)
I HAVE been playing around setting up input fields for the user to fill out
im just having problems withe
dom = raw_input("the domain name")
ad_user.Put('userPrincipalName',user['login']+'@ [(dom]')
can you point to a good ref ?
PS i think this uses the com moudle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090421/69a3027d/attachment-0001.html>
More information about the Python-list
mailing list