Пример #1
0
        public void Contains_Should_ReturnTrue_WhenOneDistingusihedNameIsContainedWithinAnother()
        {
            // Arrange
            var dn1 = new DistinguishedName("CN=TestUser,OU=People,DC=example,DC=com");
            var dn2 = new DistinguishedName("OU=People,DC=example,DC=com");
            var dn3 = new DistinguishedName("DC=example,DC=com");

            // Act

            // Assert
            Assert.True(dn2.Contains(dn1));
            Assert.True(dn3.Contains(dn1));
            Assert.True(dn3.Contains(dn2));
        }
 /// <summary>
 /// returns true, if all nameattributes of name are part fo otherName
 /// </summary>
 private bool IsNamePartOfOtherName(DistinguishedName name, DistinguishedName otherName)
 {
     for (int i = 0; i < name.Count; i++)
     {
         if (!otherName.Contains(name[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #3
0
 /// <summary>
 /// Determines whether this user is an application account.
 /// </summary>
 /// <returns><c>true</c> if this user is an application account; otherwise, <c>false</c>.</returns>
 public bool IsApplicationAccount()
 {
     return(SamAccountName.EndsWith("-APP", StringComparison.InvariantCultureIgnoreCase) ||
            DistinguishedName.Contains(",OU=Application Accounts,"));
 }
Пример #4
0
 /// <summary>
 /// Determines whether this user is an service account.
 /// </summary>
 /// <returns><c>true</c> if this user is an service account; otherwise, <c>false</c>.</returns>
 public bool IsServiceAccount()
 {
     return(SamAccountName.EndsWith("-SVC", StringComparison.InvariantCultureIgnoreCase) ||
            DistinguishedName.Contains(",OU=Service Accounts,"));
 }
Пример #5
0
 /// <summary>
 /// Determines whether this user is an administrative account.
 /// </summary>
 /// <returns><c>true</c> if this user is an administrative account; otherwise, <c>false</c>.</returns>
 public bool IsAdministrativeAccount()
 {
     return(SamAccountName.EndsWith("-ADM", StringComparison.InvariantCultureIgnoreCase) ||
            DistinguishedName.Contains(",OU=Administrative Accounts,"));
 }