Automatic mapping between LDAP users and local users

Post here if you have some suggestions or you want to request a new feature.

Automatic mapping between LDAP users and local users

Postby fred9176 » Fri Feb 15, 2013 7:48 am

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
fred9176
 
posts 23
 
joined Mon Jul 02, 2012 9:29 am

Re: Automatic mapping between LDAP users and local users

Postby FTP » Mon Feb 18, 2013 12:50 pm

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"..":") 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
FTP
Site Admin
 
posts 1506
 
joined Tue Sep 29, 2009 6:09 am

Re: Automatic mapping between LDAP users and local users

Postby WebFTP » Tue Dec 13, 2016 6:00 pm

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
WebFTP
 
posts 3
 
joined Tue Dec 13, 2016 5:53 pm

Re: Automatic mapping between LDAP users and local users

Postby FTP » Wed Dec 14, 2016 10:36 am

OK, it should be "DOPTION_LDAP_MAPPING_STR". You can check out all the key strings under "lua/ServerInterface.lua".
FTP
Site Admin
 
posts 1506
 
joined Tue Sep 29, 2009 6:09 am

Re: Automatic mapping between LDAP users and local users

Postby WebFTP » Thu Jan 12, 2017 1:09 pm

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
WebFTP
 
posts 3
 
joined Tue Dec 13, 2016 5:53 pm

Re: Automatic mapping between LDAP users and local users

Postby WebFTP » Fri Apr 07, 2017 1:51 pm

Can you help me with my problem?
The condition "if c_UserExist (strDomain, strADUser) == false then" does not work properly!

Regards,
Andreas
WebFTP
 
posts 3
 
joined Tue Dec 13, 2016 5:53 pm

Re: Automatic mapping between LDAP users and local users

Postby FTP » Wed Apr 19, 2017 11:49 am

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)
FTP
Site Admin
 
posts 1506
 
joined Tue Sep 29, 2009 6:09 am


Return to Suggestions & Wishlist

Who is online

Users browsing this forum: No registered users and 2 guests