sid

How can I convert from a SID to an account name in C#

此生再无相见时 提交于 2019-11-27 06:47:52
I have a C# application that scans a directory and gathers some information. I would like to display the account name for each file. I can do this on the local system by getting the SID for the FileInfo object, and then doing: string GetNameFromSID( SecurityIdentifier sid ) { NTAccount ntAccount = (NTAccount)sid.Translate( typeof( NTAccount ) ); return ntAccount.ToString(); } However, this does not work for files on a network, presumably because the Translate() function only works with local user accounts. I thought maybe I could do an LDAP lookup on the SID, so I tried the following: string

How to get the logon SID in C#

馋奶兔 提交于 2019-11-27 05:18:33
How does one retrieve the Windows Logon SID in C# .net? (not the user SID, but the unique new one for each session) I'm afraid you have to resort to using P/Invoke. There's an example how to do it at pinvoke.net (please see the bottom of the page): Result = GetTokenInformation(WindowsIdentity.GetCurrent().Token, TOKEN_INFORMATION_CLASS.TokenSessionId , TokenInformation , TokenInfLength , out TokenInfLength ); Please note that I changed the example by altering just one line, I replaced TOKEN_INFORMATION_CLASS.TokenUser with TOKEN_INFORMATION_CLASS.TokenSessionId which is exactly what you need.

删除锁

僤鯓⒐⒋嵵緔 提交于 2019-11-27 04:48:02
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username, l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time FROM v l o c k e d o b j e c t l , a l l o b j e c t s o , v locked_object l, all_objects o, v l o c k e d o ​ b j e c t l , a l l o ​ b j e c t s o , v session s WHERE l.object_id = o.object_id AND l.session_id = s.sid ORDER BY sid, s.serial# ; ALTER system KILL session ‘SID,serial#’; 如果发生 ora-00031:标记要终止的会话。 select spid, osuser, s.program from v s e s s i o n s , v session s, v s e s s i o n s , v process p where s.paddr = p.addr and s.sid =197; 在linux上, kill

IdentityServer4搭建和使用

烈酒焚心 提交于 2019-11-27 02:21:37
1.NuGet引用 IdentityServer4.AccessTokenValidation 2.Startup.cs注册 services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.ExpireTimeSpan = TimeSpan.FromMinutes(60); //到期时间 options.Cookie.Name = "lym.Cookies"; //名称 }); 3.注册中件间 app.UseAuthentication(); 4.使用细节 var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);//获取实例 identity.AddClaim(new Claim(ClaimTypes.Sid, "Sid"));//添加 identity.AddClaim(new Claim(ClaimTypes.Name, "Name"));//添加 await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,

mysql 聚集函数和分组

不羁岁月 提交于 2019-11-27 01:08:40
1、sc表的内容如下: mysql> select * from sc order by sid asc; +----+-------+-----+-------+ | ID | SID | CID | SCORE | +----+-------+-----+-------+ | 1 | 10001 | 101 | 70 | | 2 | 10001 | 102 | 80 | | 4 | 10001 | 103 | 90 | | 3 | 10008 | 103 | 50 | | 5 | 10008 | 101 | 60 | | 6 | 10008 | 102 | 70 | +----+-------+-----+-------+ 6 rows in set 2、求所有成绩的平均值 mysql> select avg(score) from sc; +------------+ | avg(score) | +------------+ | 70.0000 | +------------+ 1 row in set 考虑,select sid,cid,avg(score) from sc;的结果是什么? 这个时候平均值只有一个,而sid,cid都是有多个,这种情况,sid,cid取第一条记录的值,sid,cid的值也没有意义。如果某一列所有的值都相同,才有意义。 3

mysql 内连接 左连接 右连接 外连接

拈花ヽ惹草 提交于 2019-11-27 01:08:31
mysql> desc student; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | ID | int(11) | NO | PRI | 0 | | | NAME | varchar(16) | YES | | NULL | | | AGE | int(11) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 3 rows in set mysql> desc sc; +-------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+----------------+ | ID | int(11) | NO | PRI | NULL | auto_increment | | SID |

Convert a username to a SID string in C#/.NET

China☆狼群 提交于 2019-11-26 11:58:33
问题 There\'s a question about converting from a SID to an account name; there isn\'t one for the other way around. How do you convert a username to a SID string, for example, to find out which HKEY_USERS subkey relates to a user of a given name? 回答1: The podcast tells me I should ask, and answer, questions when they're not answered on SO already. Here goes. The easy way, with .NET 2.0 and up, is this: NTAccount f = new NTAccount("username"); SecurityIdentifier s = (SecurityIdentifier) f.Translate

How SID is different from Service name in Oracle tnsnames.ora

蹲街弑〆低调 提交于 2019-11-26 09:05:23
问题 Why do I need two of them? When I have to use one or another? 回答1: @DAC In short: SID = the unique name of your DB, ServiceName = the alias used when connecting Not strictly true.. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to be the files. Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com", the DBA can on the