mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-13 02:57:44 -05:00
SyncExternalUsers is deactivating ldap users #1708
Closed
opened 2025-11-02 04:10:22 -06:00 by GiteaMirror
·
51 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.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.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#1708
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @junkb on GitHub (Apr 18, 2018).
[x]):Description
i've set up and am using ldap authentication. this seems to be working fine. users in the specified ldap group are able to log in, and are able to use the system. upon a new user's initial login, they are active, and the user management panel confirms this.
however, once SyncExternalUsers runs, it decides all ldap users need to be deactivated, and does so [see logs referenced above].
once this happens, the user is still able to log in, but is shown in the user management panel as inactive, and cannot be seen by other users [for example, in explore -> users].
users can be manually reactivated, by editing that user's settings in the user management panel, and the user is then again visible, etc., but as soon as SyncExternalUsers runs again, it deactivates everyone.
@lafriks commented on GitHub (Apr 19, 2018):
Do you have user filter set
(&(objectclass=user)(samaccountname=*)(memberof=cn=vcs_users,ou=groups,dc=example,dc=com))?@lafriks commented on GitHub (Apr 19, 2018):
It should be
(&(objectclass=user)(samaccountname=%s)(memberof=cn=vcs_users,ou=groups,dc=example,dc=com))@junkb commented on GitHub (Apr 19, 2018):
no asterisk in the actual filter, no [see screen shot] - that's only appearing in the log output
i don't know go really at all, but could that asterisk be coming from
https://github.com/go-gitea/gitea/blob/master/modules/auth/ldap/ldap.go#L293 ?
it looks like userFilter might be getting explicitly set with a literal '*'?
@junkb commented on GitHub (Apr 28, 2018):
what else can i do to troubleshoot this further?
@s-hamann commented on GitHub (May 4, 2018):
I experienced similar behaviour until I set the username attribute to
sAMAccountName. Does not seem to be as optional as the docs indicate (for AD environments, at least).@hexathos commented on GitHub (May 12, 2018):
setting username to sAMAaccountName didn't help... my gitea installation with active directory backend is still deactivating users... same goes for the instance with openldap backend... ;c(
@lafriks commented on GitHub (May 13, 2018):
I can't seem to reproduce that
@hexathos commented on GitHub (May 13, 2018):
I am not that fine with go... but
524885dd65 (diff-5b36fdb03ccb6b7625fd57a6c675051dR309)returned two bools (which i assume was isadmin and isactive) while search result returns just isadmin
@liquidat commented on GitHub (May 28, 2018):
I can verify the issue - upon each run of
SyncExternalUsersthe LDAP user is deactivated. However I fail to reproduce the log message mentioned above, even in Debug mode!My user filter is much simpler:
(&(objectclass=person)(uid=%s))It is running against a freeipa LDAP server.e6b0a2dgitea/gitea:latestrunning on CentOS[x]):@okimiko commented on GitHub (May 31, 2018):
I can verfiy the issue, too. I reverted to an older image.
@sapk commented on GitHub (May 31, 2018):
We should maybe raise this issue to kind/bug tag and add to 1.5.0 release ?
@lafriks commented on GitHub (May 31, 2018):
I can not seem to reproduce this bug with either MS AD or OpenLDAP :(
@liquidat commented on GitHub (May 31, 2018):
@lafriks Any idea how we could further debug the problem? I am using the pre-build docker container.
Also, in https://github.com/go-gitea/gitea/issues/3815#issuecomment-382706926 you mentioned that the filter should contain
samaccountnameandmemberof- is this a requirement? As mentioned above I use a rather simple filter, maybe that's the problem?@lafriks commented on GitHub (May 31, 2018):
@liquidat I'm testing OpenLDAP with same configuration as in tests: https://github.com/go-gitea/gitea/blob/master/integrations/auth_ldap_test.go#L99
@liquidat commented on GitHub (Jun 7, 2018):
I realized that even if I add an admin filter which should match my user, the user is not an admin afterwards.
Maybe the ldap sync for some reason does not manage find the users? Is there any way to get more debug output of the sync in the current container build, like how many users were found?
@yamss commented on GitHub (Jun 7, 2018):
I'm having the same issue. This behavior started maybe a week ago... everything was fine before. I updated my docker image one week before this started to happen.
@lafriks commented on GitHub (Jun 7, 2018):
Can you please give your LDAP source configuration and LDAP server software being used.
@yamss commented on GitHub (Jun 7, 2018):
Using MS Active Directory:
User Filter= (sAMAccountName=%s)
Admin Filter= (&(objectCategory=Person)(memberOf=CN=GU_TSC,OU=Grupos,DC=lc,DC=gc,DC=local))
@liquidat commented on GitHub (Jun 11, 2018):
@lafriks Was this a request to provide feedback meant that everyone with this bug should answer, or only @yamss ?
@lafriks commented on GitHub (Jun 12, 2018):
@liquidat everyone can provide, the more cases are provided the better chances to find where is the problem
@liquidat commented on GitHub (Jun 13, 2018):
LDAP Source configuration:
IDMidm-c389uid=system,cn=sysaccounts,cn=etc,dc=bayz,dc=decn=users,cn=accounts,dc=bayz,dc=de(&(objectClass=inetOrgPerson)(memberOf=cn=users,cn=accounts,dc=bayz,dc=de)(uid=%s))(&(objectclass=person)(uid=%s))rwomailLDAP Server software:
@junkb commented on GitHub (Jun 14, 2018):
i've just experienced some additional developments wrt to this issue. today, for the first time, i performed a git operation using ssh rather than http, and observed the following symptom:
if i activate the user manually [e.g. via the admin panel], the symptom is gone and i'm able to perform operations successfully. after the scheduled task runs and the user gets deactivated, the symptom reappears. git operations via https don't exhibit this symptom. they work even with the user inactive, in the same way i can log into the web ui, even with an inactive user.
@junkb commented on GitHub (Jun 14, 2018):
here are my configuration details [i'm sorry, i've had to mask some particulars]
the directory server is microsoft active directory, running on windows server 2008 r2 datacenter 64 bit service pack 1
@armin1402 commented on GitHub (Jun 21, 2018):
We got the same issue here with OpenLDAP
Authentication Type: LDAP (via BindDN)
Authentication Name: gitea
Security Protocol: LDAPS
Host: IP (x.x.x.x)
Port: 7636
Bind DN: uid=XXXXXXXX,cn=users,dc=XXXXXX,dc=de
Bind Password: XXXXXXXXX
User Search Base: cn=users,dc=XXXXXXXX,dc=de
User Filter: (uid=%s)
Admin Filter: XXXXXXXX
Username Attribute: empty
Email Attribute: mail
Logfile
@armin1402 commented on GitHub (Jun 21, 2018):
It seems this isse comes up, if you do the following:
then the userid doesnt match to id.
Maybe it would make more sense, to check in ldap the username (uid, samaccountname) instead of using an id.
@junkb commented on GitHub (Jun 23, 2018):
in my case, the only local account is the administrator account. there are no other local accounts.
@xoxys commented on GitHub (Aug 6, 2018):
@lafriks Any news? The complete notification stack (Gitea/Mail) is broken as a result of this behavior...
@liquidat commented on GitHub (Oct 9, 2018):
As mentioned in bug #4067 a one fix is to fill the appropriate "Username attribute". Depending on the LDAP configuration, this might be "cn" (like described by @ghtyrant in https://github.com/go-gitea/gitea/issues/4067#issuecomment-395530981) or as in my case "uid".
Not sure if that covers all cases mentioned here. But it did for me.
@xoxys commented on GitHub (Oct 9, 2018):
Yes this "fix" works for me also. Downside: All users marching the LDAP filter will be synchronized to the local gitea database. If you have many users this might be a problem. What i would like to see is: User will be created at first login and only these useres will be synced with the ldap
@junkb commented on GitHub (Oct 9, 2018):
above in my earlier comment you can see we have
username attribute: samaccountname
so in our case, this does not avoid the symptom
@KimonHoffmann commented on GitHub (Oct 24, 2018):
I have had the same problem even though my configuration already included all the important settings discussed in this his thread.
After further analysis I noticed the "Size Limit Exceeded" error in the log file (see #3675), which wasn't obvious, because most users were synchronized anyway and all relevant user were included by sheer luck.
After fixing this issue by enabling paging, the "Active" flags were also synchronized as expected.
@liquidat commented on GitHub (Oct 24, 2018):
@junkb Maybe this comment helps?
@lafriks commented on GitHub (Oct 25, 2018):
@KimonHoffmann you can set in LDAP auth source to use paged search, this would fix size limit exceeded error.
@KimonHoffmann commented on GitHub (Oct 25, 2018):
@lafriks yes, I know, sorry for not clearly expressing what I was trying to say.
I was trying to give other people who are struggling with this error a hint on what may cause it.
What I meant to say was that in my case the fact that the Active-flags were not synchronized from LDAP was a side effect of the sync job never running to completion, because it aborted prematurely with the "Size limit exceeded" error.
Once I fixed the latter by enabling paging in the LDAP config, the Active flags were synchronized as expected.
@tonysgi commented on GitHub (Dec 5, 2018):
@KimonHoffmann I set the paging size 1000 and 2000 but I am still getting my users deactivated from Active Directory. What paging size did you use?
@KimonHoffmann commented on GitHub (Dec 6, 2018):
@tonysgi: I have the paging set to the rather low value of 200.
Please note that you can easily determine, whether or not the page size is the problem by looking for the "Size limit exceeded" message in the log, while performing a synchronization.
I might be wrong in my assessment, but from what I've learned while investigating this problem on my installation is that the synchronization process appears to first fetch all user records and if that succeeded synchronizes the active flags in a second step. So any error that makes the first step not run to completion causes the active flags to be reset.
Having a look into the logfile while the synchronization is in progress could yield pointers on what your specific problem may be.
@huapox commented on GitHub (Jan 22, 2019):
same problem! help wanted. #4402
@HarryHHung commented on GitHub (Feb 26, 2019):
In my case my problem was solved by case-sensitively setting user attributes as in the following list.
http://www.kouti.com/tables/userattributes.htm
@stale[bot] commented on GitHub (Apr 27, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@stale[bot] commented on GitHub (May 11, 2019):
This issue has been automatically closed because of inactivity. You can re-open it if needed.
@meskio commented on GitHub (Jun 28, 2019):
We are hitting this same issue. I don't think is solved.
Our log says when it disables all our users:
I check and our openldap server is configured with oclSizeLimit = 100, and on the gitea side we have marked it to
Use Paged Searchwith Page Size = 50. Our ldap contains ~550 accounts. We have theUsername attributeset touid.Any ideas of how I can help to solve this issue? Things to look into? Tests that will be useful for that?
@lafriks commented on GitHub (Jun 30, 2019):
What version are you using?
@meskio commented on GitHub (Jul 1, 2019):
We compiled ourselves gitea using the tag 1.8.3.
@clawoflight commented on GitHub (Jul 11, 2019):
same problem here, it only works if I manually specify the username attribute.
My guess is that there is a bug in the search code compared to the authentication :)
@IonicEcko commented on GitHub (Aug 7, 2019):
I am also having this issue.
Latest docker, really small MS AD (its a lab), every time the sync runs it deactivates my user. Happy to grab any logs etc needed if you can mention what and where.
@lafriks commented on GitHub (Aug 7, 2019):
please check gitea.log for any errors/warnings related to LDAP sync
@IonicEcko commented on GitHub (Aug 7, 2019):
No errors that I can see but the mess of SQL queries makes it hard to tell. I ran an update though to replicate the issue and the only bit that looked out of place was:
2019/08/07 08:03:20 ...rm/session_update.go:375:Update() [I] [SQL] UPDATE "user" SET "is_active" = ?, "updated_unix" = ? WHERE "id"=? []interface {}{false, 1565165000, 7}For reference (because I never discount my own stupidity) my settings are below. I ended up having to remove the admin filter because it never seemed to work and the user filter had to be simplified and switched from sAMAccountName to SamAccountName to match AD (with sAM it just didnt work at all).
If thats wrong, my apologies.
LDAP definitely works (my AD password works - even after deleting the account). But it deactives the account on every sync.

@stale[bot] commented on GitHub (Oct 6, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@lafriks commented on GitHub (Oct 6, 2019):
Imho this should be resolved on master branch
@s-hell commented on GitHub (Oct 28, 2019):
I have the same problem.
Started withe 1.9.3, updated to 1.9.4 and compiled the master branch. All the same error.
We are using gitea with:
ssh=2.16.5
DB=mysql
OS=CentOS7.7
@faekz0r commented on GitHub (Jan 31, 2020):
Try being case sensitive, like this: sAMAccountName