-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group Claim Augmentation does not work if display name is different from SamAccountName for Group #134
Comments
You can set what attribute is used to create group claims, and by default it's the samAccountName: Go to Central Administration > Security > LDAPCP Claim types configuration. |
Hi @NaveenKanukuntla, your analysis is perfectly correct: A possible alternative is to get the groups using method LDAPCP.GetGroupsFromActiveDirectory(), which should set the claim value of group with their samAccountName. For that you need to check the option "Use .NET helper (for Active Directory only)" in LDAPCP global configuration page. Did you consider it? |
Hi @Yvand . Thanks for the quick reply. I initially started using .NET Helper setting. But, it looks like that method does not use secure authentication, the authentication type is set to None. Hence any calls to my directory simply fails to query anything or maybe the filter is incorrect. See the ULS logs below after setting the setting to use .NET Helper method. As you can see, it completes the query in 0ms, which does not seem normal to me. Like you said, I figured that I will have to do one additional query if I use 'Query this Server' setting instead of 'Use .NET helper' setting. |
You can configure a secure connection using the authentication options (check boxes) in the LDAP connection section, at the top of LDAPCP global configuration page (you will need to delete and re-add the connection) |
Hi @Yvand . I created it multiple times. Still it did not work, hence switched back to Query LDAP Server option. I was debugging the code to see what was going on. In LDAPCP.cs, I noticed you put a comment. See below line.
the ldapServers object is empty, hence the query is failing since there are no LDAP servers to query.
What filter were you inferring to when you said // BUG: Filters must be set in an object created in this method ? EDIT : I figured what was going on, the foreach loop following the line mentioned above
Even though i saved the connection with 'Enable augmentation' never gets saved into my persistedobject store in SharePoint. Now I have to figure out why it would not save my augmentation setting. |
I did a very quick test of the augmentation, and the logs confirm that the authentication is secured, using the the authentication options that I checked when I added the connection:
Can you compare with your own logs? |
I tried to do exactly what you said and this time i selcted both 'Query this Server' and 'Use .NET Helper'. I see the following in logs
As you can see, if I select both 'Query this Server' and 'Use .NET Helper'. I see these unexpected errors for username and password that was used to connect to these 4 domains. I have verified it multiple times and the username or password is not incorrect. Hence I chose 'Query this LDAP Server' and unchecked 'Use .NET Helper' option. Then I do get the groups but they do not match because of the name vs samaccountname difference. One thing to note is user1 is local to domain contoso.com. |
I see that all connections are made with AuthenticationType "SimpleBind", while I guess you set something more secure? Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ldapUser = "contoso\spfarm"
if (!$ldapPassword) { $ldapPassword = Read-Host "Enter the password (will appear in clear text)" }
$userToAugment = "yvand"
$domainFQDN = "contoso.local"
# domainContainer must be set, otherwise UserPrincipal.FindByIdentity throsws error 0x80005000 (tested only in AD)
$domainContainer = "DC=contoso,DC=local"
$contextOptions = [System.DirectoryServices.AccountManagement.ContextOptions] "Negotiate, Signing, Sealing" # Encrypted connection, traffic unreadable in network analyzer
$contextOptions = [System.DirectoryServices.AccountManagement.ContextOptions] "SimpleBind" # LDAP traffic is in clear text
$contextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$principalContext = $null
$principalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext ($contextType, $domainFQDN, $domainContainer, $contextOptions, $ldapUser, $ldapPassword)
if ($principalContext -ne $null -and [String]::IsNullOrEmpty($principalContext.ConnectedServer) -eq $false) {
$principalContext
$user = $null
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($principalContext, $userToAugment)
$groups = $user.GetAuthorizationGroups()
# The foreach group calls an enumerator that does separate LDAP binds for each group
foreach($group in $groups) {
$group.SamAccountName
}
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Yvand, you commented earlier that "A possible alternative is to get the groups using method LDAPCP.GetGroupsFromActiveDirectory(), which should set the claim value of group with their samAccountName." I was looking at the following lines in the code of GetGroupsFromActiveDirectory(): Line 1368 in c0670eb
Line 1378 in c0670eb
Line 1382 in c0670eb
To me this looks like it's using Name and not samAccountName. Would it be possible to modify this to look at whatever is set in the claim types configuration page? |
When I try to provide access to users using an AD Group. My AD Group name is 'IT-DepartmentName'. But the display name is 'Department Name'.
So, while logging in, although claims augmentation is completed successfully, it does not match my group SamAccountName. Since during claims augmentation, it resolves to group display name and I never get access to the site due to the mis-match in Group display name vs Group SamAccountName.
The text was updated successfully, but these errors were encountered: