コード例 #1
0
 private static bool TestBanInfoFlags(IUser user, UserFlags userFlags)
 {
     if (userFlags.HasFlag(UserFlags.NotBanned) == true && user.BanInfo.IsBanned == true)
     {
         return(false);
     }
     if (userFlags.HasFlag(UserFlags.Banned) == true && user.BanInfo.IsNotBanned == true)
     {
         return(false);
     }
     return(true);
 }
コード例 #2
0
 private static bool TestUserStateFlags(IUser user, UserFlags userFlags)
 {
     if (userFlags.HasFlag(UserFlags.Offline) == true && user.UserState != UserState.None)
     {
         return(false);
     }
     if (userFlags.HasFlag(UserFlags.Online) == true && user.UserState != UserState.Online)
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
        private static bool[] SelectBanState(UserFlags userFlags)
        {
            var banStateList = new List <bool>();
            var banStateFlag = userFlags & (UserFlags.NotBanned | UserFlags.Banned);

            if (userFlags.HasFlag(UserFlags.NotBanned) == true)
            {
                banStateList.Add(false);
            }
            if (userFlags.HasFlag(UserFlags.Banned) == true)
            {
                banStateList.Add(true);
            }
            return(banStateList.ToArray());
        }
コード例 #4
0
        private static UserState[] SelectUserState(UserFlags userFlags)
        {
            var userStateList = new List <UserState>();
            var userStateFlag = userFlags & (UserFlags.Online | UserFlags.Offline);

            if (userFlags.HasFlag(UserFlags.Online) == true)
            {
                userStateList.Add(UserState.Online);
            }
            if (userFlags.HasFlag(UserFlags.Offline) == true)
            {
                userStateList.Add(UserState.None);
            }
            return(userStateList.ToArray());
        }
コード例 #5
0
        private static Authority[] GetAuthorities(UserFlags userFlags)
        {
            var authorityList = new List <Authority>();
            var authorityFlag = userFlags & (UserFlags.Admin | UserFlags.Member | UserFlags.Guest);

            if (userFlags.HasFlag(UserFlags.Admin) == true || authorityFlag == UserFlags.None)
            {
                authorityList.Add(Authority.Admin);
            }
            if (userFlags.HasFlag(UserFlags.Member) == true || authorityFlag == UserFlags.None)
            {
                authorityList.Add(Authority.Member);
            }
            if (userFlags.HasFlag(UserFlags.Guest) == true || authorityFlag == UserFlags.None)
            {
                authorityList.Add(Authority.Guest);
            }
            return(authorityList.ToArray());
        }
コード例 #6
0
        public PacLogonInfo(byte[] node)
        {
            var pacStream = new NdrBinaryReader(node);

            Header = new RpcHeader(pacStream);

            LogonTime         = pacStream.ReadFiletime();
            LogoffTime        = pacStream.ReadFiletime();
            KickOffTime       = pacStream.ReadFiletime();
            PwdLastChangeTime = pacStream.ReadFiletime();
            PwdCanChangeTime  = pacStream.ReadFiletime();
            PwdMustChangeTime = pacStream.ReadFiletime();

            var userName        = pacStream.ReadRPCUnicodeString();
            var userDisplayName = pacStream.ReadRPCUnicodeString();
            var logonScript     = pacStream.ReadRPCUnicodeString();
            var profilePath     = pacStream.ReadRPCUnicodeString();
            var homeDirectory   = pacStream.ReadRPCUnicodeString();
            var homeDrive       = pacStream.ReadRPCUnicodeString();

            LogonCount       = pacStream.ReadShort();
            BadPasswordCount = pacStream.ReadShort();

            var userSid  = pacStream.ReadRid();
            var groupSid = pacStream.ReadRid();

            // Groups information
            var groupCount   = pacStream.ReadInt();
            var groupPointer = pacStream.ReadInt();

            UserFlags = (UserFlags)pacStream.ReadInt();

            // sessionKey
            pacStream.Read(new byte[16]);

            var serverNameString = pacStream.ReadRPCUnicodeString();
            var domainNameString = pacStream.ReadRPCUnicodeString();
            var domainIdPointer  = pacStream.ReadInt();

            // reserved1
            pacStream.Read(new byte[8]);

            UserAccountControl = (UserAccountControlFlags)pacStream.ReadInt();

            SubAuthStatus        = pacStream.ReadInt();
            LastSuccessfulILogon = pacStream.ReadFiletime();
            LastFailedILogon     = pacStream.ReadFiletime();
            FailedILogonCount    = pacStream.ReadInt();

            // reserved3
            pacStream.ReadInt();

            // Extra SIDs information
            var extraSidCount   = pacStream.ReadInt();
            var extraSidPointer = pacStream.ReadInt();

            var resourceDomainIdPointer = pacStream.ReadInt();
            var resourceGroupCount      = pacStream.ReadInt();
            var resourceGroupPointer    = pacStream.ReadInt();

            UserName        = userName.ReadString(pacStream);
            UserDisplayName = userDisplayName.ReadString(pacStream);
            LogonScript     = logonScript.ReadString(pacStream);
            ProfilePath     = profilePath.ReadString(pacStream);
            HomeDirectory   = homeDirectory.ReadString(pacStream);
            HomeDrive       = homeDrive.ReadString(pacStream);

            // Groups data
            var groupSids = ParseAttributes(pacStream, groupCount, groupPointer);

            // Server related strings
            ServerName = serverNameString.ReadString(pacStream);
            DomainName = domainNameString.ReadString(pacStream);

            if (domainIdPointer != 0)
            {
                DomainSid = pacStream.ReadSid();
            }

            UserSid  = userSid.AppendTo(DomainSid);
            GroupSid = groupSid.AppendTo(DomainSid);

            GroupSids = groupSids.Select(g => g.AppendTo(DomainSid)).ToList();

            if (UserFlags.HasFlag(UserFlags.LOGON_EXTRA_SIDS))
            {
                ExtraSids = ParseExtraSids(pacStream, extraSidCount, extraSidPointer).Select(e => e.AppendTo(DomainSid)).ToList();
            }

            if (resourceDomainIdPointer != 0)
            {
                ResourceDomainSid = pacStream.ReadSid();
            }

            if (UserFlags.HasFlag(UserFlags.LOGON_RESOURCE_GROUPS))
            {
                ResourceGroups = ParseAttributes(
                    pacStream,
                    resourceGroupCount,
                    resourceGroupPointer
                    ).Select(g => g.AppendTo(DomainSid)).ToList();
            }
        }