moov2 / Orchard.ActiveDirectoryAuthorization

Module for Orchard CMS that handles authorization for active directory users.
19 stars 15 forks source link

Getting Email Enhancement? #1

Closed Excommunicated closed 11 years ago

Excommunicated commented 11 years ago

Just wondering if there was plans to add the ability to Add the users email to the UserPart for this module, I added it my self inside the CreateUserForActiveDirectoryIfNotExists method using the following, but was just wondering if there was a plan to add it into the library..? I know it's not great, but it works for the situation we are using it for..

            string[] domainAndUserName = activeDirectoryUser.UserName.Split('\\');
            string email = "";
            if (domainAndUserName.Length == 2)
            {
                PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainAndUserName[0]);
                UserPrincipal up = UserPrincipal.FindByIdentity(ctx, activeDirectoryUser.UserName);

                if (up != null)
                    email = up.EmailAddress.ToLowerInvariant();
            }
            CreateUser(new CreateUserParams(activeDirectoryUser.UserName, "password", email, String.Empty, String.Empty, true));
Excommunicated commented 11 years ago

Oh and P.S. Great work on this module.. Saved me a bunch of time doing it myself... :)

peterkeating commented 11 years ago

Nice work! You should submit a pull request with this change and we will give it a test and merge it in.

peterkeating commented 11 years ago

See #2