Hi there,
I was just wondering if anyone had any knowledge of any scripts, VB ideally for group policy - that will add a list of FTP sites and passwords.
We currently have a group of users, when they have a PC swap out they require our administrators to set up the FTP details again, we are looking to streamline this and maybe just run a quick script to do this?
Any help would be amazing.
Thanks guys
Toby
Script to add FTP sites and passwords
Moderator: Project members
-
- 500 Command not understood
- Posts: 1
- Joined: 2013-09-24 10:04
- First name: Toby
- Last name: Wilmington
-
- 500 Command not understood
- Posts: 2
- Joined: 2014-03-18 16:29
- First name: Vijay
- Last name: Sarathy
- Location: Bangalore, Karnataka
Re: Script to add FTP sites and passwords
My best bet would be to use SimpleXML to manipulate the XML file.
Use simplexml_load_file to open the file. Make sure you have read/write access to that file.
Use the SimpleXMLElement class to add and delete nodes.
Alternatively, try this code-
$user = $xml->Users->addChild('User');
$user->addAttribute('Name', $user_name);
add_option($user,'Pass',md5($password));
add_option($user,'Group',null);
add_option($user,'Bypass server userlimit','0');
add_option($user,'User Limit','0');
add_option($user,'IP Limit','0');
add_option($user,'Enabled','1');
add_option($user,'Comments','none');
add_option($user,'ForceSsl','0');
$filter = $user->addChild('IpFilter');
$filter->addChild('Disallowed');
$filter->addChild('Allowed');
$permissions = $user->addChild('Permissions');
$permission = $permissions->addChild('Permission');
$permission->addAttribute('Dir', str_replace("/","\\",$ftpUserFolder));
add_option($permission,'FileRead','1');
add_option($permission,'FileWrite','1');
add_option($permission,'FileDelete','1');
add_option($permission,'FileAppend','1');
add_option($permission,'DirCreate','1');
add_option($permission,'DirDelete','1');
add_option($permission,'DirList','1');
add_option($permission,'DirSubdirs','1');
add_option($permission,'IsHome','1');
add_option($permission,'AutoCreate','1');
$speed = $user->addChild('SpeedLimits');
$speed->addAttribute('DlType', '1');
$speed->addAttribute('DlLimit', '10');
$speed->addAttribute('ServerDlLimitBypass', '0');
$speed->addAttribute('UlType', '1');
$speed->addAttribute('UlLimit', '10');
$speed->addAttribute('ServerUlLimitBypass', '0');
$speed->addChild('Download');
$speed->addChild('Upload');
if(!$rv = $xml->asXML($xmlfile)){
echo ('SimpleXML could not write file');
return false;
}
//Change file encoding from UTF8 to ISO-8859-1
$dom = new DOMDocument("1.0","ISO-8859-1");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
if(!$dom->load($xmlfile) || !$dom->save($xmlfile)){
echo ('DOMDocument could not change file enconding from UTF8 to ISO-8859-1');
Use simplexml_load_file to open the file. Make sure you have read/write access to that file.
Use the SimpleXMLElement class to add and delete nodes.
Alternatively, try this code-
$user = $xml->Users->addChild('User');
$user->addAttribute('Name', $user_name);
add_option($user,'Pass',md5($password));
add_option($user,'Group',null);
add_option($user,'Bypass server userlimit','0');
add_option($user,'User Limit','0');
add_option($user,'IP Limit','0');
add_option($user,'Enabled','1');
add_option($user,'Comments','none');
add_option($user,'ForceSsl','0');
$filter = $user->addChild('IpFilter');
$filter->addChild('Disallowed');
$filter->addChild('Allowed');
$permissions = $user->addChild('Permissions');
$permission = $permissions->addChild('Permission');
$permission->addAttribute('Dir', str_replace("/","\\",$ftpUserFolder));
add_option($permission,'FileRead','1');
add_option($permission,'FileWrite','1');
add_option($permission,'FileDelete','1');
add_option($permission,'FileAppend','1');
add_option($permission,'DirCreate','1');
add_option($permission,'DirDelete','1');
add_option($permission,'DirList','1');
add_option($permission,'DirSubdirs','1');
add_option($permission,'IsHome','1');
add_option($permission,'AutoCreate','1');
$speed = $user->addChild('SpeedLimits');
$speed->addAttribute('DlType', '1');
$speed->addAttribute('DlLimit', '10');
$speed->addAttribute('ServerDlLimitBypass', '0');
$speed->addAttribute('UlType', '1');
$speed->addAttribute('UlLimit', '10');
$speed->addAttribute('ServerUlLimitBypass', '0');
$speed->addChild('Download');
$speed->addChild('Upload');
if(!$rv = $xml->asXML($xmlfile)){
echo ('SimpleXML could not write file');
return false;
}
//Change file encoding from UTF8 to ISO-8859-1
$dom = new DOMDocument("1.0","ISO-8859-1");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
if(!$dom->load($xmlfile) || !$dom->save($xmlfile)){
echo ('DOMDocument could not change file enconding from UTF8 to ISO-8859-1');
Vijay