BugNET

Open source issue tracking & project management
Welcome to BugNET Register | Login |

BugNET Forums

 
  Forum  Support  General Support  Active Directory Integration and User Role Auto Assignment
Previous Previous
 
Next Next
New Post 7/10/2008 9:58 AM
User is offline mattjevans
2 posts
No Ranking


Active Directory Integration and User Role Auto Assignment 

Hi,

 

I've got the latest version working great with AD integration. New users are automatically added in to the BugNet DB. However, they dont appear to be auto assigned roles when they are added. Is this the intentional behaviour? I want a new user to be automatically assigned a role to a particular project.

 

On another point. I had to modify the the Authentication HTTP module because the following check does not always work as i get some clients with the type as 'Negotiate':

if (request.IsAuthenticated && (request.LogonUserIdentity.AuthenticationType == "NTLM")

This code seems to fix the Problem:

if (request.IsAuthenticated
                    && (request.LogonUserIdentity.AuthenticationType == "NTLM)" || request.LogonUserIdentity.AuthenticationType == "Negotiate")

 

Thanks,

Matt.

 

 
New Post 7/10/2008 11:13 AM
User is offline admin
658 posts
bugnetproject.com
1st Level Poster




Re: Active Directory Integration and User Role Auto Assignment 

 mattjevans wrote

Hi,

 

I've got the latest version working great with AD integration. New users are automatically added in to the BugNet DB. However, they dont appear to be auto assigned roles when they are added. Is this the intentional behaviour? I want a new user to be automatically assigned a role to a particular project.

 

On another point. I had to modify the the Authentication HTTP module because the following check does not always work as i get some clients with the type as 'Negotiate':

if (request.IsAuthenticated && (request.LogonUserIdentity.AuthenticationType == "NTLM")

This code seems to fix the Problem:

if (request.IsAuthenticated
                    && (request.LogonUserIdentity.AuthenticationType == "NTLM)" || request.LogonUserIdentity.AuthenticationType == "Negotiate")

 

Thanks,

Matt.

I believe the auto assignment functionality was added as a new feature and I forgot to also implement it in the atthentication module. If you have been modifying the code you can implement the autoassignment of roles by adding this code to the authentication module.

//auto assign user to roles
                List<Role> roles = Role.GetAllRoles();
                foreach (Role r in roles)
                {
                    if (r.AutoAssign)
                        Role.AddUserToRole(user.UserName, r.Id);
                }

I will add that and the fix you provided here the authentication module.

Thanks!


Davin Dubeau
BugNET - Core Developer

 
New Post 7/11/2008 2:17 AM
User is offline mattjevans
2 posts
No Ranking


Re: Active Directory Integration and User Role Auto Assignment 

Hi Davin,

 

Thanks for the speedy response. I have modded the authentication module and it is now working perfectly! Below is the code i have working:

 

if (enabled)
            {
                if (request.IsAuthenticated
                    && (request.LogonUserIdentity.AuthenticationType == "NTLM" || request.LogonUserIdentity.AuthenticationType == "Negotiate"))
                {
                    //check if the user exists in the database
                    MembershipUser user = UserIT.GetUser(HttpContext.Current.User.Identity.Name);

                    if (user == null)
                    {
                        try
                        {
                            UserProperties userprop = GetUserProperties(HttpContext.Current.User.Identity.Name);
                            //create a new user with the current identity and a random password.
                            UserIT.CreateUser(HttpContext.Current.User.Identity.Name, Membership.GeneratePassword(7, 2), userprop.Email);
                            user = UserIT.GetUser(HttpContext.Current.User.Identity.Name);

                        }
                        catch (Exception ex)
                        {
                            Log.Error(String.Format("Unable to add new user {0} to BugNET application.", HttpContext.Current.User.Identity.Name), ex);
                        }
                    }

                    //auto assign user to roles
                    List<Role> roles = Role.GetAllRoles();
                    foreach (Role r in roles)
                    {
                        if (r.AutoAssign)
                            Role.AddUserToRole(user.UserName, r.Id);
                    }
                } 
            }

 

 

Regards,

 

Matt.

 

 

 
New Post 7/11/2008 10:59 AM
User is offline smoss
114 posts
www.orbitsolutions.co.za
5th Level Poster


Re: Active Directory Integration and User Role Auto Assignment 

Hi Guys,

Thanks Matt.

I logged an issue for this posting so that the changes dont get lost in the woodwork of time and chaos.

http://support.bugnetproject.com/Bugs/BugDetail.aspx?bid=707

 
Previous Previous
 
Next Next
  Forum  Support  General Support  Active Directory Integration and User Role Auto Assignment

Forum Policy

These Discussion Forums are dedicated to the discussion of the BugNET issue tracker.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:
1. No Advertising.
2. No Flaming or Trolling.
3. No Profanity, Racism, or Prejudice.
4. Site Moderators have the final word on approving/removing a thread or post or comment.
5. English language posting only, please.