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
Automatic mapping between LDAP users and local users
-
- Posts: 23
- Joined: Mon Jul 02, 2012 9:29 am
-
- Site Admin
- Posts: 2083
- Joined: Tue Sep 29, 2009 6:09 am
Re: Automatic mapping between LDAP users and local users
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":
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
-
- Posts: 3
- Joined: Tue Dec 13, 2016 5:53 pm
Re: Automatic mapping between LDAP users and local users
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
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
-
- Site Admin
- Posts: 2083
- Joined: Tue Sep 29, 2009 6:09 am
Re: Automatic mapping between LDAP users and local users
OK, it should be "DOPTION_LDAP_MAPPING_STR". You can check out all the key strings under "lua/ServerInterface.lua".
-
- Posts: 3
- Joined: Tue Dec 13, 2016 5:53 pm
Re: Automatic mapping between LDAP users and local users
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?
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
-
- Posts: 3
- Joined: Tue Dec 13, 2016 5:53 pm
Re: Automatic mapping between LDAP users and local users
Can you help me with my problem?
The condition "if c_UserExist (strDomain, strADUser) == false then" does not work properly!
Regards,
Andreas
The condition "if c_UserExist (strDomain, strADUser) == false then" does not work properly!
Regards,
Andreas
-
- Site Admin
- Posts: 2083
- Joined: Tue Sep 29, 2009 6:09 am
Re: Automatic mapping between LDAP users and local users
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)