Esempio n. 1
0
        public UserCreateStatus AddDNNUser(UserInfo AuthenticationUser)
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
            PortalSecurity objSecurity = new PortalSecurity();

            Entities.Users.UserController objDNNUsers = new Entities.Users.UserController();
            UserController objAuthUsers = new UserController();

            Entities.Users.UserInfo objDNNUser = (Entities.Users.UserInfo)AuthenticationUser;
            int AffiliateId = -1;

            if (HttpContext.Current.Request.Cookies["AffiliateId"] != null)
            {
                AffiliateId = int.Parse(HttpContext.Current.Request.Cookies["AffiliateId"].Value);
            }

            int UserID = -1;
            UserCreateStatus createStatus;
            createStatus = Entities.Users.UserController.CreateUser(ref objDNNUser);
            UserID = objDNNUser.UserID;

            if (AuthenticationUser.AuthenticationExists && UserID > -1)
            {
                AuthenticationUser.UserID = UserID;
                AddUserRoles(_portalSettings.PortalId, AuthenticationUser);
            }

            return createStatus;
        }
Esempio n. 2
0
        private void FillUserInfo( DirectoryEntry UserEntry, UserInfo userInfo )
        {

            userInfo.IsSuperUser = false;
            userInfo.Username = userInfo.Username;
            userInfo.Membership.Approved = true;
            userInfo.Membership.LastLoginDate = DateTime.Today;
            userInfo.Email = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_EMAIL].Value );
            userInfo.CName = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_CNAME].Value.ToString() );
            userInfo.DisplayName = Utilities.CheckNullString(UserEntry.Properties[ADSI.Configuration.ADSI_DISPLAYNAME].Value);
            if (userInfo.DisplayName == "")
            {
                userInfo.DisplayName = userInfo.CName;
            }
            userInfo.DistinguishedName = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_DISTINGUISHEDNAME].Value.ToString() );
            userInfo.sAMAccountName = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_ACCOUNTNAME].Value.ToString() );
            userInfo.Profile.FirstName = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_FIRSTNAME].Value );
            userInfo.Profile.LastName = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_LASTNAME].Value );
            userInfo.Profile.Street = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_STREET].Value );
            userInfo.Profile.City = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_CITY].Value );
            userInfo.Profile.Region = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_REGION].Value );
            userInfo.Profile.PostalCode = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_POSTALCODE].Value );
            userInfo.Profile.Country = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_COUNTRY].Value );
            userInfo.Profile.Telephone = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_TELEPHONE].Value );
            userInfo.Profile.Fax = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_FAX].Value );
            userInfo.Profile.Cell = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_CELL].Value );
            userInfo.Profile.Website = Utilities.CheckNullString( UserEntry.Properties[ADSI.Configuration.ADSI_WEBSITE].Value );
            userInfo.AuthenticationExists = true;
            // obtain firstname from username if admin has not enter enough user info
            if( userInfo.Profile.FirstName.Length == 0 )
            {
                userInfo.Profile.FirstName = Utilities.TrimUserDomainName( userInfo.Username );
            }
        }
Esempio n. 3
0
        public override bool IsAuthenticationMember( GroupInfo AuthenticationGroup, UserInfo AuthenticationUser )
        {
            if( ! AuthenticationGroup.IsPopulated )
            {
                PopulateMembership( AuthenticationGroup );
            }

            return AuthenticationGroup.AuthenticationMember.Contains( AuthenticationUser.DistinguishedName );
        }
Esempio n. 4
0
        public override UserInfo GetUser( string LoggedOnUserName )
        {
            //Dim adsiConfig As Authentication.ADSI.Configuration = Authentication.ADSI.Configuration.GetConfig(_portalSettings.PortalId)
            UserInfo objAuthUser;
            try
            {
                if( _adsiConfig.ADSINetwork )
                {
                    DirectoryEntry entry;

                    entry = Utilities.GetUserEntryByName( LoggedOnUserName );

                    if( entry != null )
                    {
                        objAuthUser = new UserInfo();

                        string location = Utilities.GetEntryLocation( entry );
                        if( location.Length == 0 )
                        {
                            location = _adsiConfig.ConfigDomainPath;
                        }

                        objAuthUser.PortalID = _portalSettings.PortalId;
                        objAuthUser.GUID = entry.NativeGuid;
                        objAuthUser.Location = location;
                        objAuthUser.Username = LoggedOnUserName;
                        objAuthUser.PrincipalName = Utilities.TrimUserDomainName( LoggedOnUserName ) + "@" + location;
                        objAuthUser.Username = LoggedOnUserName;
                        objAuthUser.Membership.Password = Utilities.GetRandomPassword();

                        FillUserInfo( entry, objAuthUser );
                    }
                    else
                    {
                        objAuthUser = GetSimplyUser( LoggedOnUserName );
                    }
                }
                else // could not find it in AD, so populate user object with minumum info
                {
                    objAuthUser = GetSimplyUser( LoggedOnUserName );
                }

                return objAuthUser;
            }
            catch( COMException exc )
            {
                Exceptions.LogException( exc );
                return null;
            }
        }
Esempio n. 5
0
        public override UserInfo GetUser( string LoggedOnUserName, string LoggedOnPassword )
        {
            UserInfo objAuthUser;

            if( ! _adsiConfig.ADSINetwork )
            {
                return null;
            }

            try
            {
                DirectoryEntry entry = Utilities.GetUserEntryByName( LoggedOnUserName );

                //Check authenticated
                if( ! IsAuthenticated( entry.Path, LoggedOnUserName, LoggedOnPassword ) )
                {
                    return null;
                }

                // Return authenticated if no error
                objAuthUser = new UserInfo();

                string location = Utilities.GetEntryLocation( entry );
                if( location.Length == 0 )
                {
                    location = _adsiConfig.ConfigDomainPath;
                }

                objAuthUser.PortalID = _portalSettings.PortalId;
                objAuthUser.GUID = entry.NativeGuid;
                objAuthUser.Username = LoggedOnUserName;
                objAuthUser.Location = location;
                objAuthUser.PrincipalName = Utilities.TrimUserDomainName( LoggedOnUserName ) + "@" + location;
                objAuthUser.Username = LoggedOnUserName;
                objAuthUser.Membership.Password = LoggedOnPassword;

                FillUserInfo( entry, objAuthUser );

                return objAuthUser;
            }
            catch( Exception exc )
            {
                Exceptions.LogException( exc );
                return null;
            }
        }
Esempio n. 6
0
        private UserInfo GetSimplyUser( string UserName )
        {
            UserInfo objAuthUser = new UserInfo();

            objAuthUser.PortalID = _portalSettings.PortalId;
            objAuthUser.GUID = "";
            objAuthUser.Username = UserName;
            objAuthUser.FirstName = Utilities.TrimUserDomainName( UserName );
            objAuthUser.LastName = Utilities.GetUserDomainName( UserName );
            objAuthUser.IsSuperUser = false;
            objAuthUser.Location = _adsiConfig.ConfigDomainPath;
            objAuthUser.PrincipalName = Utilities.TrimUserDomainName( UserName ) + "@" + objAuthUser.Location;
            objAuthUser.DistinguishedName = Utilities.ConvertToDistinguished( UserName, Path.GC );

            string strEmail = _adsiConfig.DefaultEmailDomain;
            if( strEmail.Length != 0 )
            {
                if( strEmail.IndexOf( "@" ) == - 1 )
                {
                    strEmail = "@" + strEmail;
                }
                strEmail = objAuthUser.FirstName + strEmail;
            }
            else
            {
                strEmail = objAuthUser.FirstName + "@" + objAuthUser.LastName + ".com"; // confusing?
            }
            // Membership properties
            objAuthUser.Username = UserName;
            objAuthUser.Email = strEmail;
            objAuthUser.Membership.Approved = true;
            objAuthUser.Membership.LastLoginDate = DateTime.Today;
            objAuthUser.Membership.Password = Utilities.GetRandomPassword(); //Membership.GeneratePassword(6)
            objAuthUser.AuthenticationExists = false;

            return objAuthUser;
        }
 public abstract bool IsAuthenticationMember(GroupInfo AuthenticationGroup, UserInfo AuthenticationUser);
 public bool IsAuthenticationMember( GroupInfo AuthenticationGroup, UserInfo AuthenticationUser )
 {
     return AuthenticationProvider.Instance( this.mProviderTypeName ).IsAuthenticationMember( AuthenticationGroup, AuthenticationUser );
 }
Esempio n. 9
0
 /// <summary>
 /// </summary>
 /// <remarks>
 /// This routine is more accurated,
 /// Prevent user assign to admin role in case user logon as LOCAL\Administrator
 /// </remarks>
 public static void AddUserRoles(int PortalID, UserInfo AuthenticationUser)
 {
     GroupController objGroupController = new GroupController();
     ArrayList colGroup = objGroupController.GetGroups();
     RoleController objRoles = new RoleController();
     GroupInfo authenticationGroup;
     try
     {
         foreach( GroupInfo tempLoopVar_authenticationGroup in colGroup )
         {
             authenticationGroup = tempLoopVar_authenticationGroup;
             if( objGroupController.IsAuthenticationMember( authenticationGroup, AuthenticationUser ) )
             {
                 objRoles.AddUserRole( PortalID, AuthenticationUser.UserID, authenticationGroup.RoleID, Null.NullDate, Null.NullDate );
             }
         }
     }
     catch( Exception exc )
     {
         Exceptions.LogException( exc );
     }
 }