Security Identifier (SID) is a unique name which is assigned by a Windows Domain controller during the log on process that is used to identify a user or a group.
Every user has one and here is how to find it using C#:
using System.Security.Principal;
using System.DirectoryServices.AccountManagement;
public static SecurityIdentifier GetDoaminAccountSecurityIdentifier(string account, string container)
{
SecurityIdentifier securityIdentifier = null;
using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, null, container))
{
UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, account);
if (user != null)
{
securityIdentifier = user.Sid;
user.Dispose();
}
}
return securityIdentifier;
}
Once we have the SID we can now add the user to any shared folder on the network.
Posted
3 Oct 2009 7:24 AM
by
Gal Ratner