예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        public ActiveDirectoryUser(ADUser adUser)
        {
            this.City = adUser.City;
            this.Company = adUser.Company;
            this.Country = adUser.Country;
            this.Department = adUser.Department;
            this.EmailAddress = adUser.EmailAddress;
            this.Extension = adUser.Extension;
            this.Fax = adUser.Fax;
            this.FirstName = adUser.FirstName;
            this.HomePhone = adUser.HomePhone;
            this.LastName = adUser.LastName;
            this.LoginName = adUser.LoginName;
            this.LoginNameWithDomain = adUser.LoginName;
            this.MiddleName = adUser.MiddleName;
            this.Mobile = adUser.Mobile;
            this.PostalCode = adUser.PostalCode;
            this.State = adUser.State;
            this.StreetAddress = adUser.StreetAddress;
            this.UserAccountControl = adUser.UserAccountControl;
            this.Title = adUser.Title;



        }
예제 #2
0
파일: ADHelper.cs 프로젝트: gpanayir/sffwk
        /// <summary>
        /// Obtiene un usuario por nombre sin tener en cuenta las credenciales del usuario
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public ADUser User_Get_ByName(String userName)
        {

            ADUser wADUser = null;
            DirectoryEntry userDirectoryEntry = null;
            try
            {
                userDirectoryEntry = this.User_Get(userName);
                if (userDirectoryEntry != null)
                {
                    wADUser = new ADUser(userDirectoryEntry);
                    userDirectoryEntry.Close();
                    userDirectoryEntry.Dispose();
                }

                return wADUser;
            }
            catch (Exception ex)
            {
                throw ProcessActiveDirectoryException(ex);
            }

        }
예제 #3
0
파일: ADHelper.cs 프로젝트: gpanayir/sffwk
        /// <summary>
        /// Retorna la lista de usuarios pertenecientes a un determinado grupo
        /// </summary>
        /// <param name="groupName">Nombre del grupo</param>
        /// <returns></returns>
        public List<ADUser> Users_SearchByGroupName(String groupName)
        {

            List<ADUser> userlist = new List<ADUser>();
            ADUser wADUser = null;
            DirectoryEntry directoryEntryUser = null;
            DirectorySearcher deSearch = new DirectorySearcher(_directoryEntrySearchRoot);
            //deSearch.Filter = "(&(objectClass=group)(SAMAccountName=" + groupName + "))";
            deSearch.Filter = string.Format("(&(objectClass=group)(SAMAccountName={0}))", groupName);
            try
            {
               

                SearchResult results = deSearch.FindOne();
                if (results != null)
                {

                    DirectoryEntry deGroup = new DirectoryEntry(results.Path, LDAPUser, LDAPPassword);

                    System.DirectoryServices.PropertyCollection pColl = deGroup.Properties;

                    int count = pColl["member"].Count;



                    for (int i = 0; i < count; i++)
                    {

                        string respath = results.Path;

                        string[] pathnavigate = respath.Split("CN".ToCharArray());

                        respath = pathnavigate[0];

                        string objpath = pColl["member"][i].ToString();

                        string path = string.Concat(respath, objpath);

                        directoryEntryUser = new DirectoryEntry(path, LDAPUser, LDAPPassword);

                        wADUser = new ADUser(directoryEntryUser);

                        userlist.Add(wADUser);

                        directoryEntryUser.Close();
                        directoryEntryUser.Dispose();

                    }
                    deGroup.Close();
                    deGroup.Dispose();

                }
                deSearch.Dispose();
                return userlist;

            }

            catch (Exception ex)
            {
                throw ProcessActiveDirectoryException(ex);
            }



        }
예제 #4
0
        /// <summary>
        /// Obtiene un usuario por nombre sin tener en cuenta las credenciales del usuario
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public ADUser User_Get_ByName(String userName)
        {

            ADUser wADUser = null;
            DirectoryEntry userDirectoryEntry = null;
            try
            {
                string domaunAndUser = String.Format( DomaunAndUserFormat, _LDAPDomainName,userName);
                userDirectoryEntry = this.User_Get(domaunAndUser);
                if (userDirectoryEntry != null)
                {
                    wADUser = new ADUser(userDirectoryEntry);
                    userDirectoryEntry.Close();
                    userDirectoryEntry.Dispose();
                }

                return wADUser;
            }
            catch (Exception ex)
            {
                throw ProcessActiveDirectoryException(ex);
            }

        }