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

.NET (Core and Framework)

 
GeneralRe: Microsoft.VisualBasic.FileIO.TextFieldParser Pin
#realJSOP9-Sep-16 7:28
mve#realJSOP9-Sep-16 7:28 
AnswerRe: Microsoft.VisualBasic.FileIO.TextFieldParser Pin
Richard MacCutchan9-Sep-16 21:40
mveRichard MacCutchan9-Sep-16 21:40 
QuestionAssembly. Pin
Member 111616259-Sep-16 2:00
Member 111616259-Sep-16 2:00 
AnswerRe: Assembly. Pin
Pete O'Hanlon9-Sep-16 2:17
mvePete O'Hanlon9-Sep-16 2:17 
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 
You might have better luck using the System.DirectoryServices.AccountManagement namespace[^]. It provides a much cleaner interface than the raw DirectoryServices version.
VB.NET
Using context As New PrincipalContext(ContextType.Domain)
    Using user As New UserPrincipal(context, 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
        End If
        
        user.PasswordNeverExpires = True
        user.UserCannotChangePassword = 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(context, IdentityType.Name, MemberOf)
            If group IsNot Nothing Then
                group.Members.Add(user)
                group.Save()
            End If
        End Using
    End Using
End Using


Using System.DirectoryServices.AccountManagement[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer



modified 9-Sep-16 9:03am.

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 
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 

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.