Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to crate/delete users in Active Directory using php?

Posted on 2010-09-15
8
Medium Priority
?
360 Views
Last Modified: 2013-12-12
I have created a system for administrating users, that is based on mysql, and PHP. I need to conect to AD-and create and delete users, from the webpage? How can I do this.

I have tested out some php examples that connect to AD throug LDAP, and read out data. But i need somethinh that can write back.

Regards
Anders
0
Comment
Question by:andoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 5

Expert Comment

by:chqshaitan
ID: 33682264
hi,

there are various commandline utils that you can do this with. You didnt mention what version of ad you are running on so this may not be correct, but check out

ds add --> http://technet.microsoft.com/en-us/library/cc731279%28WS.10%29.aspx
0
 

Author Comment

by:andoman
ID: 33682455
Thanks, the link looks interresting.

But I`m running the AD on a Windows 2003-server. And I want to connect with php running on apache on linux.

So I`m looking for a tool that run commands on a linux-box, that connect to AD and do stuff.

Some other tip?
0
 
LVL 5

Accepted Solution

by:
chqshaitan earned 375 total points
ID: 33682610
ah from linux.. interesting :) nothing to stop you from enabling telnet on the windows server(except for the security concerns) and writing a script that will send the commands via telnet.

Or you could write a small php commandline app that runs on the windows domain controller, and checks a text file(database table) say on the linux box, and creates the associated user?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:chqshaitan
ID: 33682631
or you could look at linking linux and ad together.

have a read of the following :

http://technet.microsoft.com/en-us/magazine/2008.12.linux.aspx
0
 
LVL 5

Expert Comment

by:sgdought
ID: 33917798
To do what you want, use an LDAP connection:

See this link for a examples and troubleshooting:
http://forums.devshed.com/ldap-programming-76/ldap-addition-of-users-in-php-from-shell-474487.html

0
 
LVL 4

Expert Comment

by:Antyrael
ID: 33947312
I made some php scripts to create and delete users in AD.
All the info I needed was available on php.net.
Check this site for more info: http://www.php.net/manual/en/ref.ldap.php

The commands you will mostly be interested in are:
ldap_add to create an AD object
ldap_mod_add to add the user to AD groups
ldap_delete to delete an AD object.

ldap_rename and ldap_modify can also be very useful.

Good luck.
0
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 375 total points
ID: 34759584
0
 

Author Closing Comment

by:andoman
ID: 34760073
Managed to do what I wanted with telnet, expect sripts, and PHP.

php, is calling an expectscript with a set of arguments that is pushed to the windows-server via telnet(unsecure, and unencrypted).

Used asadd, and dsrm, thats part of windows command line tool, to modify AD.

IMPORTANT:
Do not use this solution in any unsecure enviorment.!!
It is a much better solution som implement ldap-support.
0

Featured Post

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question