Page 1 of 1
Automatic mapping between LDAP users and local users
Posted: Fri Feb 15, 2013 7:48 am
by fred9176
Hello,
Would it be possible to add an automatic mapping between ldap accounts and local accounts ?
Actually, we have to create a local user for each ldap user with a different name and map every user in the authentication ldap tab.
We could use a specific prefix or suffix to automaticcaly map users.
For example, if my ldap user is j.doe, we could create a local user called j.doe-local (or ldap_j.doe, ...) and WingFTp should automaticaly know that the 2 users are linked.
Regards,
Fred
Re: Automatic mapping between LDAP users and local users
Posted: Mon Feb 18, 2013 12:50 pm
by FTP
OK, I will give you a Lua script for creating a local user and adding AD-to-Local mapping automatically,
You can add the following script into "Event Manager -> FTP Events (HTTP Events and SSH Events) -> OnUserLoggedIn -> Lua Script":
Code: Select all
local strDomain = "%Domain"
local strRootDir = "c:/temp"
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_ADUSER_MAPPING_STR,strMapping.."\r\n"..strADUser..":"..strLocalUser)
end
Re: Automatic mapping between LDAP users and local users
Posted: Tue Dec 13, 2016 6:00 pm
by WebFTP
Hello,
Which option should I use instead of DOPTION_ADUSER_MAPPING_STR in the string c_SetOptionStr (strDomain, ...) when I use the LDAP connector?
Regards,
Andreas
Re: Automatic mapping between LDAP users and local users
Posted: Wed Dec 14, 2016 10:36 am
by FTP
OK, it should be "DOPTION_LDAP_MAPPING_STR". You can check out all the key strings under "lua/ServerInterface.lua".
Re: Automatic mapping between LDAP users and local users
Posted: Thu Jan 12, 2017 1:09 pm
by WebFTP
Hello
At the moment, I am adjusting the script so that there is no automatic mapping for existing local users. Unfortunately my change does not work as desired. Can you help me?
Code: Select all
local strDomain = "%Domain"
local strRootDir = "c:/temp"
local strADUser = "%Name"
local strLocalUser = "%Name".."_local"
local strMapping = c_GetOptionStr(strDomain,DOPTION_LDAP_MAPPING_STR)
if c_UserExist(strDomain,strADUser) == false then
if not string.find(strMapping, "%Name"..":") 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
end
Re: Automatic mapping between LDAP users and local users
Posted: Fri Apr 07, 2017 1:51 pm
by WebFTP
Can you help me with my problem?
The condition "if c_UserExist (strDomain, strADUser) == false then" does not work properly!
Regards,
Andreas
Re: Automatic mapping between LDAP users and local users
Posted: Wed Apr 19, 2017 11:49 am
by FTP
It means the local user "%Name" already exists, anyway, you can print that username in the server logs:
Code: Select all
c_AddSystemLog("Username: %Name", 0)