예제 #1
0
        /// <summary>
        ///     Gets the name of the manager.
        /// </summary>
        /// <param name="userPrincipal">The user principal.</param>
        /// <returns>System.String.</returns>
        /// TODO Edit XML Comment Template for GetManagerName
        public static string GetManagerName(this UserPrincipal userPrincipal)
        {
            var managerDistinguishedName =
                userPrincipal.GetManagerDistinguishedName();

            if (managerDistinguishedName.IsNullOrWhiteSpace())
            {
                return(null);
            }
            using (var managerUserPrincipal = UserPrincipal.FindByIdentity(
                       PrincipalContextExtensions.GetPrincipalContext(),
                       IdentityType.DistinguishedName,
                       managerDistinguishedName))
            {
                return(managerUserPrincipal?.Name);
            }
        }
예제 #2
0
        /// <summary>
        ///     Gets the name of the managed by.
        /// </summary>
        /// <param name="groupPrincipal">The group principal.</param>
        /// <returns>System.String.</returns>
        /// TODO Edit XML Comment Template for GetManagedByName
        public static string GetManagedByName(
            this GroupPrincipal groupPrincipal)
        {
            var managedByDistinguishedName =
                groupPrincipal.GetManagedByDistinguishedName();

            if (managedByDistinguishedName.IsNullOrWhiteSpace())
            {
                return(null);
            }

            using (var principalContext =
                       PrincipalContextExtensions.GetPrincipalContext())

                using (var managedByUserPrincipal =
                           UserPrincipalExtensions.FindByDistinguishedName(
                               principalContext,
                               managedByDistinguishedName))
                {
                    return(managedByUserPrincipal?.Name);
                }
        }