示例#1
0
        /// <summary>
        ///     Obtain user from Windows Active Directory using simple Username format
        /// </summary>
        /// <remarks>
        ///     Reserved for simple network which have single domain and logon username in simple format
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public static DirectoryEntry GetUser0(string Name)
        {
            // Create search object then assign required params to get user entry in Active Directory
            Search         objSearch = new Search(GetRootDomain());
            DirectoryEntry userEntry;

            objSearch.AddFilter(Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.person.ToString());
            objSearch.AddFilter(Configuration.ADSI_ACCOUNTNAME, CompareOperator.Is, Name);
            userEntry = objSearch.GetEntry();

            return(userEntry);
        }
示例#2
0
        /// <summary>
        ///     Obtain user from Windows Active Directory using UPN format - USERNAME@DOMAIN
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public static DirectoryEntry GetUserByUPN0(string Name, Domain RootDomain)
        {
            // Create search object then assign required params to get user entry in Active Directory
            Search         objSearch = new Search(RootDomain);
            DirectoryEntry userEntry;

            // UPN is unique in entire Windows network
            objSearch.AddFilter(Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.person.ToString());
            objSearch.AddFilter(Configuration.ADSI_UPN, CompareOperator.Is, Name);
            userEntry = objSearch.GetEntry();

            return(userEntry);
        }
示例#3
0
        public static DirectoryEntry GetGroupEntryByName(string GroupName)
        {
            Domain RootDomain = GetRootDomain();
            Search objSearch  = new Search(RootDomain);

            objSearch.AddFilter(Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.group.ToString());
            objSearch.AddFilter(Configuration.ADSI_ACCOUNTNAME, CompareOperator.Is, GroupName);

            DirectoryEntry groupEntry = objSearch.GetEntry();

            if (groupEntry != null)
            {
                return(groupEntry);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        ///     Obtain user from Windows Active Directory using UPN format - USERNAME@DOMAIN
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public static DirectoryEntry GetUserByUPN0( string Name, Domain RootDomain )
        {
            // Create search object then assign required params to get user entry in Active Directory
            Search objSearch = new Search( RootDomain );
            DirectoryEntry userEntry;

            // UPN is unique in entire Windows network
            objSearch.AddFilter( Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.person.ToString() );
            objSearch.AddFilter( Configuration.ADSI_UPN, CompareOperator.Is, Name );
            userEntry = objSearch.GetEntry();

            return userEntry;
        }
示例#5
0
        /// <summary>
        ///     Obtain user from Windows Active Directory using simple Username format
        /// </summary>
        /// <remarks>
        ///     Reserved for simple network which have single domain and logon username in simple format
        /// </remarks>
        /// <history>
        ///     [tamttt]	08/01/2004	Created
        /// </history>
        public static DirectoryEntry GetUser0( string Name )
        {
            // Create search object then assign required params to get user entry in Active Directory
            Search objSearch = new Search( GetRootDomain() );
            DirectoryEntry userEntry;

            objSearch.AddFilter( Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.person.ToString() );
            objSearch.AddFilter( Configuration.ADSI_ACCOUNTNAME, CompareOperator.Is, Name );
            userEntry = objSearch.GetEntry();

            return userEntry;
        }
示例#6
0
        public static DirectoryEntry GetGroupEntryByName( string GroupName )
        {
            Domain RootDomain = GetRootDomain();
            Search objSearch = new Search( RootDomain );

            objSearch.AddFilter( Configuration.ADSI_CLASS, CompareOperator.Is, ObjectClass.group.ToString() );
            objSearch.AddFilter( Configuration.ADSI_ACCOUNTNAME, CompareOperator.Is, GroupName );

            DirectoryEntry groupEntry = objSearch.GetEntry();

            if( groupEntry != null )
            {
                return groupEntry;
            }
            else
            {
                return null;
            }
        }