Feature #42: Active Directory Interop Upgrade

AD Interop moved to Disco.Services; Supports multi-domain environments,
sites, and searching restricted with OUs.
This commit is contained in:
Gary Sharp
2014-04-10 17:58:04 +10:00
parent b841c6b2c0
commit db73cc1a12
218 changed files with 6383 additions and 2535 deletions
+1
View File
@@ -15,6 +15,7 @@ namespace Disco.Models.ClientServices
public string DeviceSerialNumber { get; set; }
public string DeviceUUID { get; set; }
public string DeviceDNSDomainName { get; set; }
public string DeviceComputerName { get; set; }
public bool DeviceIsPartOfDomain { get; set; }
+5 -1
View File
@@ -38,6 +38,7 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -46,6 +47,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BI\Job\LocationModes.cs" />
<Compile Include="Interop\ActiveDirectory\ActiveDirectoryDomain.cs" />
<Compile Include="Interop\ActiveDirectory\ActiveDirectoryOrganisationalUnit.cs" />
<Compile Include="Interop\ActiveDirectory\ActiveDirectorySearchResult.cs" />
<Compile Include="Services\Authorization\IAuthorizationToken.cs" />
<Compile Include="Services\Authorization\IClaimNavigatorItem.cs" />
<Compile Include="Services\Authorization\IRoleToken.cs" />
@@ -168,7 +172,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_StartDate="2011/7/1" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_StartDate="2011/7/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" />
</VisualStudio>
</ProjectExtensions>
<PropertyGroup>
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectoryDomain
{
public string DnsName { get; private set; }
public string NetBiosName { get; private set; }
public string DistinguishedName { get; private set; }
public List<string> SearchContainers { get; private set; }
public ActiveDirectoryDomain(string DnsName, string NetBiosName, string DistinguishedName, List<string> SearchContainers)
{
this.DnsName = DnsName;
this.NetBiosName = NetBiosName;
this.DistinguishedName = DistinguishedName;
this.SearchContainers = SearchContainers;
}
public void UpdateSearchContainers(IEnumerable<string> Containers)
{
this.SearchContainers = Containers.ToList();
}
}
}
@@ -1,19 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectoryGroup : IActiveDirectoryObject
{
public string Name { get; set; }
public string DistinguishedName { get; set; }
public string Domain { get; set; }
public string SamAccountName { get; set; }
public string DistinguishedName { get; set; }
public string SecurityIdentifier { get; set; }
public string CommonName { get; set; }
public string Name { get; set; }
public List<string> MemberOf { get; set; }
public string NetBiosId { get { return string.Format(@"{0}\{1}", Domain, SamAccountName); } }
}
}
@@ -1,21 +1,23 @@
using System;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectoryMachineAccount : IActiveDirectoryObject
{
public string DistinguishedName { get; set; }
public string DnsName { get; set; }
public string Domain { get; set; }
public string Name { get; set; }
public Guid NetbootGUID { get; set; }
public string SecurityIdentifier { get; set; }
public string Path { get; set; }
public string SamAccountName { get; set; }
public string SecurityIdentifier { get; set; }
public string DistinguishedName { get; set; }
public string Path { get; set; }
public string Name { get; set; }
public string DnsName { get; set; }
public Guid NetbootGUID { get; set; }
public bool IsCriticalSystemObject { get; set; }
public Dictionary<string, object[]> LoadedProperties { get; set; }
@@ -23,10 +25,11 @@ namespace Disco.Models.Interop.ActiveDirectory
{
return new User
{
Id = this.SamAccountName,
UserId = this.Domain + "\\" + this.SamAccountName,
DisplayName = this.Name
};
}
public string NetBiosId { get { return string.Format(@"{0}\{1}", Domain, SamAccountName); } }
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectoryOrganisationalUnit
{
public string Name { get; set; }
public string Domain { get; set; }
public string DistinguishedName { get; set; }
public List<ActiveDirectoryOrganisationalUnit> Children { get; set; }
}
}
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectorySearchResult
{
public ActiveDirectoryDomain Domain { get; set; }
public string SearchRoot { get; set; }
public SearchResult Result { get; set; }
}
}
@@ -8,25 +8,29 @@ namespace Disco.Models.Interop.ActiveDirectory
{
public class ActiveDirectoryUserAccount : IActiveDirectoryObject
{
public string DisplayName { get; set; }
public string DistinguishedName { get; set; }
public string Domain { get; set; }
public string Email { get; set; }
public string GivenName { get; set; }
public List<string> Groups { get; set; }
public string Name { get; set; }
public string SamAccountName { get; set; }
public string DistinguishedName { get; set; }
public string SecurityIdentifier { get; set; }
public string Path { get; set; }
public string Phone { get; set; }
public string SamAccountName { get; set; }
public string Name { get; set; }
public string DisplayName { get; set; }
public string Email { get; set; }
public string Surname { get; set; }
public string GivenName { get; set; }
public string Phone { get; set; }
public List<string> Groups { get; set; }
public Dictionary<string, object[]> LoadedProperties { get; set; }
public User ToRepositoryUser()
{
return new User
{
Id = this.SamAccountName,
UserId = this.Domain + "\\" + this.SamAccountName,
DisplayName = this.DisplayName,
Surname = this.Surname,
GivenName = this.GivenName,
@@ -35,5 +39,6 @@ namespace Disco.Models.Interop.ActiveDirectory
};
}
public string NetBiosId { get { return string.Format(@"{0}\{1}", Domain, SamAccountName); } }
}
}
@@ -1,17 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Disco.Models.Interop.ActiveDirectory
{
public interface IActiveDirectoryObject
{
string DistinguishedName { get; set; }
string SecurityIdentifier { get; set; }
string Domain { get; set; }
string SamAccountName { get; set; }
string NetBiosId { get; }
string Name { get; set; }
}
+22 -2
View File
@@ -22,8 +22,8 @@ namespace Disco.Models.Repository
public int DeviceProfileId { get; set; }
public int? DeviceBatchId { get; set; }
[StringLength(24)]
public string ComputerName { get; set; }
[StringLength(50), Column("ComputerName")]
public string DeviceDomainId { get; set; }
public string AssignedUserId { get; set; }
public DateTime? LastNetworkLogonDate { get; set; }
@@ -67,6 +67,26 @@ namespace Disco.Models.Repository
return this.SerialNumber;
}
[NotMapped]
public string ComputerName
{
get
{
var index = DeviceDomainId.IndexOf('\\');
return index < 0 ? DeviceDomainId : DeviceDomainId.Substring(index + 1);
}
}
[NotMapped]
public string ComputerDomainName
{
get
{
var index = DeviceDomainId.IndexOf('\\');
return index < 0 ? null : DeviceDomainId.Substring(0, index);
}
}
public enum DecommissionReasons
{
EndOfLife = 0,
+24 -4
View File
@@ -9,8 +9,8 @@ namespace Disco.Models.Repository
{
public class User
{
[StringLength(50), Key]
public string Id { get; set; }
[StringLength(50), Key, Column("Id")]
public string UserId { get; set; }
[StringLength(200)]
public string DisplayName { get; set; }
@@ -30,14 +30,34 @@ namespace Disco.Models.Repository
[InverseProperty("UserId")]
public virtual IList<Job> Jobs { get; set; }
[NotMapped, Obsolete("Should be using Combined Domain\\User format - UserId")]
public string Id
{
get
{
var index = UserId.IndexOf('\\');
return index < 0 ? UserId : UserId.Substring(index + 1);
}
}
[NotMapped]
public string Domain
{
get
{
var index = UserId.IndexOf('\\');
return index < 0 ? null : UserId.Substring(0, index);
}
}
public override string ToString()
{
return string.Format("{0} ({1})", this.DisplayName, this.Id);
return string.Format("{0} ({1})", this.DisplayName, this.UserId);
}
public void UpdateSelf(User u)
{
if (!this.Id.Equals(u.Id, StringComparison.InvariantCultureIgnoreCase))
if (!this.UserId.Equals(u.UserId, StringComparison.InvariantCultureIgnoreCase))
throw new ArgumentException("User Id's do not match", "u");
if (this.Surname != u.Surname)
@@ -6,7 +6,8 @@ namespace Disco.Models.Services.Jobs.JobLists
public class JobTableItemModel : JobSearchResultItem
{
public int JobId { get; set; }
#pragma warning disable 809
[Obsolete("Use [int] JobId instead")]
public override string Id
{
@@ -20,6 +21,7 @@ namespace Disco.Models.Services.Jobs.JobLists
this.JobId = int.Parse(value);
}
}
#pragma warning restore 618
public DateTime OpenedDate { get; set; }
public DateTime? ClosedDate { get; set; }
public string JobTypeId { get; set; }
@@ -30,6 +32,7 @@ namespace Disco.Models.Services.Jobs.JobLists
public int? DeviceAddressId { get; set; }
public string DeviceAddress { get; set; }
public string OpenedTechUserId { get; set; }
public string OpenedTechUserFriendlyId { get; set; }
public string OpenedTechUserDisplayName { get; set; }
public string StatusDescription { get; set; }
public string StatusId { get; set; }
@@ -13,7 +13,7 @@ namespace Disco.Models.Services.Searching
public string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.Id, this.ComputerName); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3}", this.Id, this.AssignedUserId, this.AssignedUserDisplayName, this.AssetNumber); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3} {4}", this.Id, this.AssignedUserId.Substring(0, this.AssignedUserId.IndexOf('\\')), this.AssignedUserId, this.AssignedUserDisplayName, this.AssetNumber); } }
public string AssetNumber { get; set; }
public string AssignedUserDescription
@@ -13,11 +13,12 @@ namespace Disco.Models.Services.Searching
public virtual string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1}; {2})", this.Id, this.UserId, this.DeviceSerialNumber); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3}", this.Id, this.UserId, this.DeviceSerialNumber, this.UserDisplayName); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3} {4}", this.Id, this.UserId.Substring(0, this.UserId.IndexOf('\\')), this.UserId, this.DeviceSerialNumber, this.UserDisplayName); } }
public string DeviceSerialNumber { get; set; }
public string UserId { get; set; }
public string UserFriendlyId { get; set; }
public string UserDisplayName { get; set; }
}
}
@@ -13,7 +13,7 @@ namespace Disco.Models.Services.Searching
public string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.DisplayName, this.Id); } }
public string ScoreValue { get { return string.Format("{0} {1}", this.Id, this.DisplayName); } }
public string ScoreValue { get { return string.Format("{0} {1} {2}", this.Id.Substring(0, this.Id.IndexOf('\\')), this.Id, this.DisplayName); } }
public int AssignedDevicesCount { get; set; }
public string DisplayName { get; set; }