diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2025-04-22 21:51:47 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2025-04-22 21:51:47 +0300 |
| commit | f33925e973cfaa9be4d46abd81f63afe787c6607 (patch) | |
| tree | 8765cbd70e13bcf2386343f1d7475b3bbb306869 /Software/Visual_Studio/Tango.Web | |
| parent | f0d2b8a0c3014aea6030c2ab0847755e5f67a6c0 (diff) | |
| download | Tango-f33925e973cfaa9be4d46abd81f63afe787c6607.tar.gz Tango-f33925e973cfaa9be4d46abd81f63afe787c6607.zip | |
Prevent AD group check using AD Graph API.
Diffstat (limited to 'Software/Visual_Studio/Tango.Web')
| -rw-r--r-- | Software/Visual_Studio/Tango.Web/ActiveDirectory/ActiveDirectoryManager.cs | 64 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Web/Tango.Web.csproj | 4 |
2 files changed, 35 insertions, 33 deletions
diff --git a/Software/Visual_Studio/Tango.Web/ActiveDirectory/ActiveDirectoryManager.cs b/Software/Visual_Studio/Tango.Web/ActiveDirectory/ActiveDirectoryManager.cs index 0a0a1d476..b96241612 100644 --- a/Software/Visual_Studio/Tango.Web/ActiveDirectory/ActiveDirectoryManager.cs +++ b/Software/Visual_Studio/Tango.Web/ActiveDirectory/ActiveDirectoryManager.cs @@ -30,43 +30,43 @@ namespace Tango.Web.ActiveDirectory return authResult; } - public List<Group> GetUserGroups(String email) - { - var authResult = GetAppAuthenticationResult(); - ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(new Uri($"https://graph.windows.net/{WebConfig.TENANT_ID}"), async () => await Task.FromResult(authResult.AccessToken)); - var user = activeDirectoryClient.Users.Where(x => x.UserPrincipalName == email).ExecuteSingleAsync().Result; + //public List<Group> GetUserGroups(String email) + //{ + // var authResult = GetAppAuthenticationResult(); + // ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(new Uri($"https://graph.windows.net/{WebConfig.TENANT_ID}"), async () => await Task.FromResult(authResult.AccessToken)); + // var user = activeDirectoryClient.Users.Where(x => x.UserPrincipalName == email).ExecuteSingleAsync().Result; - var userFetcher = (IUserFetcher)user; + // var userFetcher = (IUserFetcher)user; - List<Group> groups = new List<Group>(); + // List<Group> groups = new List<Group>(); - IPagedCollection<IDirectoryObject> pagedCollection = userFetcher.MemberOf.ExecuteAsync().Result; - do - { - List<IDirectoryObject> directoryObjects = pagedCollection.CurrentPage.ToList(); - foreach (IDirectoryObject directoryObject in directoryObjects) - { - if (directoryObject is Group) - { - var group = directoryObject as Group; - groups.Add(group); - } - } - pagedCollection = pagedCollection.GetNextPageAsync().Result; - } while (pagedCollection != null); + // IPagedCollection<IDirectoryObject> pagedCollection = userFetcher.MemberOf.ExecuteAsync().Result; + // do + // { + // List<IDirectoryObject> directoryObjects = pagedCollection.CurrentPage.ToList(); + // foreach (IDirectoryObject directoryObject in directoryObjects) + // { + // if (directoryObject is Group) + // { + // var group = directoryObject as Group; + // groups.Add(group); + // } + // } + // pagedCollection = pagedCollection.GetNextPageAsync().Result; + // } while (pagedCollection != null); - return groups; - } + // return groups; + //} - public bool IsUserMemberOf(String group, String email) - { - return GetUserGroups(email).Exists(x => x.DisplayName == group); - } + //public bool IsUserMemberOf(String group, String email) + //{ + // return GetUserGroups(email).Exists(x => x.DisplayName == group); + //} - public bool CanUserAccessCurrentEnvironment(String email) - { - var groups = GetUserGroups(email); - return groups.Exists(x => x.DisplayName == WebConfig.ENVIRONMENT_GROUP); - } + //public bool CanUserAccessCurrentEnvironment(String email) + //{ + // var groups = GetUserGroups(email); + // return groups.Exists(x => x.DisplayName == WebConfig.ENVIRONMENT_GROUP); + //} } } diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj index 0e729fbd2..cc348f764 100644 --- a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj +++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj @@ -188,7 +188,9 @@ <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath> </Reference> - <Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="Microsoft.WindowsAzure.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + </Reference> <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> |
