Hello,
So i found this script on a new local user created when logging in via LDAP first time - is there any way to enable 2FA by default vi scripting aswell - and maybe give me a guiding hand on how to do it?
Script below:
local strDomain = "%Domain"
local strRootDir = "c:/Test"
local strADUser = "%Name"
local strLocalUser = "local_".."%Name"
local strMapping = c_GetOptionStr(strDomain,DOPTION_ADUSER_MAPPING_STR)
if not string.find(strMapping, "%Name"..":", 0, true) then
if c_UserExist(strDomain,strLocalUser) == false then
local strPassword = md5( (c_GetTimeUS() + c_GetRandom())..c_GetServerID().."mypassword" )
c_AddUser(strDomain,strLocalUser, strPassword, 63, 1, 1)
c_AddUserDirectory(strDomain,strLocalUser, strRootDir.."/"..strADUser, "/", true, true, true, true, true, true, false, false, false, true, false, false)
c_MkDir(strRootDir.."/"..strADUser)
end
c_SetOptionStr(strDomain,DOPTION_LDAP_MAPPING_STR,strMapping.."\r\n"..strADUser..":"..strLocalUser)
end
2FA enabled when new user is created
-
- Site Admin
- Posts: 2115
- Joined: Tue Sep 29, 2009 6:09 am
Re: 2FA enabled when new user is created
Which version of WingFTP are you running? Maybe you can try the below script:
local strDomain = "%Domain"
local strRootDir = "c:/Test"
local strADUser = "%Name"
local strLocalUser = "local_".."%Name"
local strMapping = c_GetOptionStr(strDomain,DOPTION_ADUSER_MAPPING_STR)
if not string.find(strMapping, "%Name"..":", 0, true) then
if c_UserExist(strDomain,strLocalUser) == false then
local strPassword = md5( (c_GetTimeUS() + c_GetRandom())..c_GetServerID().."mypassword" )
c_AddUser(strDomain,strLocalUser, strPassword, 63, 1, 1)
c_AddUserDirectory(strDomain,strLocalUser, strRootDir.."/"..strADUser, "/", true, true, true, true, true, true, false, false, false, true, false, false)
c_MkDir(strRootDir.."/"..strADUser)
local user = c_GetUser(strDomain, strLocalUser)
if user ~= nil then
user.oldpassword = user.password
user.enable_two_factor = 1
AddUser(strDomain, user)
end
end
c_SetOptionStr(strDomain,DOPTION_LDAP_MAPPING_STR,strMapping.."\r\n"..strADUser..":"..strLocalUser)
en
local strDomain = "%Domain"
local strRootDir = "c:/Test"
local strADUser = "%Name"
local strLocalUser = "local_".."%Name"
local strMapping = c_GetOptionStr(strDomain,DOPTION_ADUSER_MAPPING_STR)
if not string.find(strMapping, "%Name"..":", 0, true) then
if c_UserExist(strDomain,strLocalUser) == false then
local strPassword = md5( (c_GetTimeUS() + c_GetRandom())..c_GetServerID().."mypassword" )
c_AddUser(strDomain,strLocalUser, strPassword, 63, 1, 1)
c_AddUserDirectory(strDomain,strLocalUser, strRootDir.."/"..strADUser, "/", true, true, true, true, true, true, false, false, false, true, false, false)
c_MkDir(strRootDir.."/"..strADUser)
local user = c_GetUser(strDomain, strLocalUser)
if user ~= nil then
user.oldpassword = user.password
user.enable_two_factor = 1
AddUser(strDomain, user)
end
end
c_SetOptionStr(strDomain,DOPTION_LDAP_MAPPING_STR,strMapping.."\r\n"..strADUser..":"..strLocalUser)
en
-
- Posts: 2
- Joined: Mon Feb 03, 2025 9:58 am
Re: 2FA enabled when new user is created
Hello,
Thanks for your help and your time, its working as intented now! Im running v7.4.1 :)
Thanks for your help and your time, its working as intented now! Im running v7.4.1 :)