Window
Because you are adding users, the user who runs the PHP program must be an administrator, and the security mode in your php.ini is not turned on, and the function of system (), exec (), PassThru () is not turned off in the shutdown function.
Then csdn the forum to see similar problems, so with a little answer, a simple idea.
http://community.csdn.net/Expert/topic/4190/4190360.xml?temp=.7591669
Can be implemented, with two methods.
First, add users to the Web
Because you are adding users, the user who runs the PHP program must be an administrator, and the security mode in your php.ini is not turned on, and the function of system (), exec (), PassThru () is not turned off in the shutdown function.
(The following instructions are for Windows2000/windows xp/windows 2003)
1, using IIS to do the Web server
If you are using IIS as a server, then the account running PHP is: Iusr_xxxxxxxx,iwam_xxxxxxx, (xxxx represents the server's computer name), then you have to add these two users to the Administrators group: Administrators. Of course, if you do this, it will pose a threat to server security.
1, using Apache as a Web server
As far as I know, Apache installed into service, then it is operating with the system permissions, so that is the case of PHP running, directly is the system permissions, has exceeded the administrator rights, then the implementation of the command is no longer words. If you modify the Apache running user, you must specify that the Apache service run user is administrator above, such as administor or system privileges.
You can then perform the Add user action in your PHP code:
According to the requirements of the landlord, describe the following code:
<?php
Define ("User_group", "users"); User group, default to users, for security, define still user group
Define ("ACTIVE", "yes"); Whether to activate the user directly after creation, yes to activate, no to Inactive
Extracting user names and passwords from the database
Suppose the table is user_info and only the field ID, user, Passwod
$sql = "Select User,password from User_info";
$result = mysql_query ($sql) or Die ("Query database Failed");
Loop Insert User
while ($array = Mysql_fetch_array ($result)) {
if (!function_exists ("System"))
Die (' Function system () not exists, add user failed. ');
Add user
@system ("NET user $array [user] $array [passwd]/active:active/add");
Add to specified group
@system ("net localgroup users $array [user]/del");
@system ("net localgroup user_group $array [USER]/add");
}
?>
The above code to add all of your database users to the local system, if you want to add a single, you can consider changing the user registration after the successful add users, this can expand their own.
Second, use PHP to do shell script to add users
In addition, I actually have a train of thought. Php.exe can be used on the server side, and there are no security issues. I have just done the test and have passed.
If your PHP is installed in c:\php\, then we use a command prompt to execute PHP scripts to add users.
PHP Code:
c:\test.php
<?php
@system ("NET user Heiyeluren Test/add");
?>
Save in c:\test.php file
Execute under CMD:
C:\php\php.exe c:\test.php
Tips:
C:\>c:\php\php.exe c:\test.php
Command completed successfully.
So from this point of view, it's perfectly possible to take the piece of code that I wrote above here to execute it, and then Php.exe act as the shell script engine. It is then written as a batch process and executed by a timed task. Of course, you can also consider using other languages to implement, such as VB/VC, and periodically go to the database to retrieve whether there are new users added, and then add users to the system.