简体   繁体   English

如何在C#应用程序中保护服务帐户?

[英]How to secure service account in c# app?

I have a service account for my application and in my application work actually as : 我有一个用于我的应用程序的服务帐户,并且在我的应用程序中,实际上是:

private string SA_myapp = "service_account_myapp@domain.com";
private string SA_myapp_pass = "5tr0ngP455w0rd";
private DirectoryEntry LDAP = new DirectoryEntry("LDAP://" + domainName, SA_myapp, SA_myapp_pass);

It's work as well but I believe it's not the good way do to this. 它也可以正常工作,但我认为这不是好方法。

How can I use my service account with a more secured way in my app ? 如何在我的应用程序中以更安全的方式使用服务帐户?

PS : C# app, Windows, active directory account PS:C#应用程序,Windows,活动目录帐户

You can use DPAPI to secure the password and store it in registry , so essentially when the service loads itself for the first time it reads the value from one registry key ( say pass_clear ) and then when it starts it check for a value in the key pass_clear , if a value is found it reads it and secures it by calling 您可以使用DPAPI来保护密码并将其存储在注册表中,因此从本质上讲,当服务首次加载自身时,它将从一个注册表项(例如pass_clear)中读取值,然后在启动时检查密钥中的值pass_clear,如果找到一个值,它将读取它并通过调用来保护它的安全

ProtectedData.Protect( pass_clear , s_aditionalEntropy, DataProtectionScope.CurrentUser );

The encrypted byte[] can then be converted to base64 string and stored in another registry key pass_secure , which can then be used by the application / service as and when it need to bind itself to the LDAP port. 然后可以将加密的byte []转换为base64字符串,并存储在另一个注册表项pass_secure中,然后在需要将其自身绑定到LDAP端口时,可以由应用程序/服务使用。

The data protection scope of current user will only allow the service account to decrypt the password and the framework does the key management for you. 当前用户的数据保护范围将仅允许服务帐户解密密码,并且框架为您执行密钥管理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 c# 中将服务安装为当前帐户 - How to Install a service as the current account in c# C#Active Directory应用程序-如何存储服务帐户凭据? - C# Active Directory App - How do I store service account credentials? 如何将新服务帐户引入现有C#Windows服务 - How to introduce a new service account to an existing C# windows service 从C#对(拥有的)Google邮件帐户的“更多”安全应用访问是什么? - What could be the “more” secure app access to (owned) google mail account from C#? 如何在 C# 中使用服务帐户登录 Google API - 凭据无效 - How to login to Google API with Service Account in C# - Invalid Credentials 如何通过服务帐户和集成安全性运行WPF(C#)应用程序 - How to run wpf(c#) application by service account and integrated security 如何在本地系统帐户下禁止C#服务启动? - How to forbid C# service from start under LocalSystem account? 如何获得SQL Server服务与C#一样运行的帐户? - How to get the account the SQL Server service runs as with C#? 如何通过服务帐户在 c# 上使用 Admob API? - How to use Admob API on c# via Service Account? 如何创建客户端 web 服务,该服务将带有安全令牌的数据发送到另一个 soap web 服务 - How to create a client web service that send data with secure token to another soap web service in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM