Click here to Skip to main content
15,888,610 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionActive Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA7-Sep-16 20:29
professionalJANAZA7-Sep-16 20:29 
AnswerRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Dave Kreskowiak8-Sep-16 6:25
mveDave Kreskowiak8-Sep-16 6:25 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA8-Sep-16 9:31
professionalJANAZA8-Sep-16 9:31 
AnswerRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming8-Sep-16 10:24
mveRichard Deeming8-Sep-16 10:24 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 1:30
professionalJANAZA9-Sep-16 1:30 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 2:56
professionalJANAZA9-Sep-16 2:56 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming9-Sep-16 3:02
mveRichard Deeming9-Sep-16 3:02 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 3:17
professionalJANAZA9-Sep-16 3:17 
With my first piece of code that I submitted I did create everything about the user except for the ability to also create the Homepath dir/drive, account options pass exp/cannot change and setting the user's group.

I was hoping this would still be valid with the already successes and enhanced my whole process.
this is the code from you with slight changes:
VB.NET
Using user As New UserPrincipal(oPrincipalContext, UserName, Password, True) ' Last parameter is "enabled"
                    user.DisplayName = DisplayName
                    user.GivenName = FirstName
                    user.MiddleName = MiddleInitial
                    user.Surname = LastName
                    user.EmailAddress = Email
                    user.Description = Description

                    user.HomeDrive = HomeDrive
                    user.HomeDirectory = HomeDirectory
                    user.ScriptPath = ScriptPath

                    If UserPrincipalName <> "" Then
                        user.UserPrincipalName = UserPrincipalName
                    Else
                        'Added this
                        user.UserPrincipalName = UserName
                    End If

                    user.PasswordNeverExpires = True
                    user.UserCannotChangePassword = True
                     'Added this
                    user.Enabled = True

                    ' Some properties are not exposed:
                    Dim myDirectoryEntry As DirectoryEntry = TryCast(user.GetUnderlyingObject(), DirectoryEntry)
                    If myDirectoryEntry IsNot Nothing Then
                        Utility.SetProperty(myDirectoryEntry, "PostalAddress", PostalAddress)
                        Utility.SetProperty(myDirectoryEntry, "StreetAddress", MailingAddress)
                        Utility.SetProperty(myDirectoryEntry, "HomePostalAddress", ResidentialAddress)
                        Utility.SetProperty(myDirectoryEntry, "Title", Title)
                        Utility.SetProperty(myDirectoryEntry, "HomePhone", HomePhone)
                        Utility.SetProperty(myDirectoryEntry, "TelephoneNumber", OfficePhone)
                        Utility.SetProperty(myDirectoryEntry, "Mobile", Mobile)
                        Utility.SetProperty(myDirectoryEntry, "FacsimileTelephoneNumber", Fax)
                        Utility.SetProperty(myDirectoryEntry, "Url", Url)
                    End If

                    user.Save()

                    ' Add the user to the specified group:
                    Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(oPrincipalContext, IdentityType.Name, MemberOF)
                        If group IsNot Nothing Then
                            group.Members.Add(user)
                            group.Save()

                        End If
                    End Using

Thanks for the fast repsonse
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming9-Sep-16 3:23
mveRichard Deeming9-Sep-16 3:23 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 3:45
professionalJANAZA9-Sep-16 3:45 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming9-Sep-16 4:11
mveRichard Deeming9-Sep-16 4:11 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 4:27
professionalJANAZA9-Sep-16 4:27 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming9-Sep-16 4:35
mveRichard Deeming9-Sep-16 4:35 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA9-Sep-16 8:08
professionalJANAZA9-Sep-16 8:08 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA11-Sep-16 19:52
professionalJANAZA11-Sep-16 19:52 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA11-Sep-16 22:37
professionalJANAZA11-Sep-16 22:37 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming12-Sep-16 1:55
mveRichard Deeming12-Sep-16 1:55 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA12-Sep-16 2:23
professionalJANAZA12-Sep-16 2:23 
GeneralRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
Richard Deeming12-Sep-16 2:29
mveRichard Deeming12-Sep-16 2:29 
PraiseRe: Active Directory : User account options, Homefolder drive and directory and memberof group Pin
JANAZA12-Sep-16 3:01
professionalJANAZA12-Sep-16 3:01 
Questionfinal year project Pin
Member 127233156-Sep-16 6:07
Member 127233156-Sep-16 6:07 
AnswerRe: final year project Pin
OriginalGriff6-Sep-16 6:10
mveOriginalGriff6-Sep-16 6:10 
AnswerRe: final year project Pin
#realJSOP7-Sep-16 1:24
mve#realJSOP7-Sep-16 1:24 
QuestionASP.Net MVC File upload Pin
Dani_el1-Sep-16 4:01
Dani_el1-Sep-16 4:01 
AnswerRe: ASP.Net MVC File upload Pin
NotPolitcallyCorrect1-Sep-16 4:11
NotPolitcallyCorrect1-Sep-16 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.