Example #1
0
        public unsafe void SetFlags(UserAccountFlags flags)
        {
            UserAllInformation info = new UserAllInformation
            {
                WhichFields        = UserWhichFields.UserAccountControl,
                UserAccountControl = flags
            };

            this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info));
        }
Example #2
0
        public void SetFlags(UserAccountFlags flags)
        {
            unsafe
            {
                UserAllInformation info = new UserAllInformation();

                info.WhichFields        = UserWhichFields.UserAccountControl;
                info.UserAccountControl = flags;

                this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info));
            }
        }
Example #3
0
        public unsafe void SetAdminComment(string comment)
        {
            UserAllInformation info = new UserAllInformation
            {
                WhichFields  = UserWhichFields.AdminComment,
                AdminComment = new UnicodeString(comment)
            };

            try
            {
                this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info));
            }
            finally
            {
                info.AdminComment.Dispose();
            }
        }
Example #4
0
        public SamUserInformation GetInformation()
        {
            using (var data = this.GetInformation(UserInformationClass.UserAllInformation))
            {
                UserAllInformation info = data.ReadStruct <UserAllInformation>();

                return(new SamUserInformation(
                           SamDomainHandle.ToDateTime(info.LastLogon),
                           SamDomainHandle.ToDateTime(info.LastLogoff),
                           SamDomainHandle.ToDateTime(info.PasswordLastSet),
                           SamDomainHandle.ToDateTime(info.AccountExpires),
                           SamDomainHandle.ToDateTime(info.PasswordCanChange),
                           SamDomainHandle.ToDateTime(info.PasswordMustChange),
                           info.UserName.Read(),
                           info.FullName.Read(),
                           info.AdminComment.Read(),
                           info.UserComment.Read(),
                           info.UserId,
                           info.PrimaryGroupId,
                           info.UserAccountControl,
                           info.PasswordExpired
                           ));
            }
        }