Hi
Is there anyone knows how to enable the password protection for a directory and create a user/password for it using XML api?
Regards,
Nam
Hi
Is there anyone knows how to enable the password protection for a directory and create a user/password for it using XML api?
Regards,
Nam
Here's the raw API1 call for setting the password protection for a directory:
You can then call this API1 function from the XML API. If you are not familiar with how to do that, feel welcome to use the PHP class Matt has written for using our XML API:Code:<cpanel Htaccess="set_pass(directory, username, password)">
http://forums.cpanel.net/showthread.php?t=111897
Thank you for your reply. It works great.
Just one more thing, what is the xml api function to turn on/off for Password protect directories?
When i tried it through cPanel, the url looks like this below:
after turning on the option:
http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?protected=1&resname=mysite&action2=Save&dir=%2Fhome%2Ffusername%2Fpublic_html%2F
after turning off the option:
http_s://mydomain.com:2083/frontend/x3/htaccess/changepro.html?resname=&action2=Save&dir=%2Fhome%2Fusername%2Fpublic_html%2F
The API call I provided earlier is for creating a user for a password protected directory. To enable or disable password protection, this is the raw API1 call:
Where directory is the directory to enable/disable protection for.Code:<cpanel Htaccess="set_protect(directory,protected,resource_name)">
Protected is 1 if directory protection is to be enabled, 0 to disable
resource_name is text you can choose to display within the password prompt that is displayed by the browser to let users know what they're logging into (e.g. Member Area).
The XML API URL for this would be:
You can view our documentation for calling API1 functions from the XML API at:Code:/xml-api/cpanel?user=username&xmlin=<cpanelaction><module>Htaccess</module><func>set_protect</func><apiversion>1</apiversion><args>/home/username/public_html/something</args><args>1</args><args>Member Area</args></cpanelaction>
http://twiki.cpanel.net/twiki/bin/vi...With_arguments
oh Cool, thank you so much!![]()
I have another post where I'm trying to compare the username and password (Reference: cPanel Forums - Search Results) Does anyone know how to compare username and passwords generated by the cPanel XML API?
Good call. Sorry about that... here is the related post... I cannot seem to figure out how to compare .htaccess username and passwords with the cPanel API.
http://forums.cpanel.net/f42/passwor...ds-157297.html
Is there anyone else that can assist with this? Thank you for any replies.
I am not 100% certain what it is that you are actually asking and it has been almost a month since your previous post.
Still playing around with .htpasswd access setup?![]()
Thank you for your reply. Let me try phrasing it another way...
You can set a password on a directory using cPanel (stored in htpasswd file), how do you programmatically using PHP authenticate a user to access that password protected directory? We do not want the web browser prompts to appear. They should authenticate directly through our PHP code.
This is the related post - http://forums.cpanel.net/f42/passwor...ds-157297.html
Thank you again for your reply and any updates or questions you may have for clarification.