C# Class pGina.Plugin.LocalMachine.LocalAccount

Afficher le fichier Open project: MutonUfoAI/pgina Class Usage Examples

Méthodes publiques

Méthode Description
GenerateRandomPassword ( int length ) : string

Generates a random password that meets most of the requriements of Windows Server when password policy complexity requirements are in effect. http://technet.microsoft.com/en-us/library/cc786468%28v=ws.10%29.aspx This generates a string with at least two of each of the following character classes: uppercase letters, lowercase letters, and digits. However, this method does not check for the existence of the username or display name within the generated password. The probability of that occurring is somewhat remote, but could happen. If that is a concern, this method could be called repeatedly until a string is returned that does not contain the username or display name.

GetGroupPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.GroupPrincipal
GetGroupPrincipal ( string groupname ) : System.DirectoryServices.AccountManagement.GroupPrincipal

Finds and returns the GroupPrincipal object if it exists, if not, returns null. This method uses PrincipalSearcher because it is faster than GroupPrincipal.FindByIdentity. The group name comparison is case insensitive.

GetUserDirectoryEntry ( string username ) : System.DirectoryServices.DirectoryEntry
GetUserPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.UserPrincipal
GetUserPrincipal ( string username ) : System.DirectoryServices.AccountManagement.UserPrincipal

Finds and returns the UserPrincipal object if it exists, if not, returns null. This method uses PrincipalSearcher because it is faster than UserPrincipal.FindByIdentity. The username comparison is case insensitive.

LocalAccount ( UserInformation userInfo ) : System
RemoveUserAndProfile ( string user, int sessionID ) : void
ScrambleUsersPassword ( string username ) : void
SyncLocalGroupsToUserInfo ( UserInformation userInfo ) : void
SyncToLocalUser ( ) : void
SyncUserInfoToLocalUser ( UserInformation userInfo ) : void
UserExists ( string strUserName ) : bool

This is a faster technique for determining whether or not a user exists on the local machine. UserPrincipal.FindByIdentity tends to be quite slow in general, so if you only need to know whether or not the account exists, this method is much faster.

Private Methods

Méthode Description
AddUserToGroup ( System.DirectoryServices.AccountManagement.UserPrincipal user, System.DirectoryServices.AccountManagement.GroupPrincipal group ) : void
Connect2share ( string share, string username, string password, uint retry, System.Boolean DISconnect ) : System.Boolean
CreateOrGetGroupPrincipal ( GroupInformation groupInfo ) : System.DirectoryServices.AccountManagement.GroupPrincipal
CreateOrGetUserPrincipal ( UserInformation userInfo ) : System.DirectoryServices.AccountManagement.UserPrincipal
GetGroups ( System.DirectoryServices.AccountManagement.UserPrincipal user ) : List

Returns a list of groups of which the user is a member. It does so in a fashion that may seem strange since one can call UserPrincipal.GetGroups, but seems to be much faster in my tests.

IsUserInGroup ( System.DirectoryServices.AccountManagement.UserPrincipal user, GroupInformation groupInfo ) : bool
IsUserInGroup ( System.DirectoryServices.AccountManagement.UserPrincipal user, System.DirectoryServices.AccountManagement.GroupPrincipal group ) : bool
IsUserInGroup ( string username, string groupname ) : bool
LocalAccount ( ) : System
RecurseDelete ( string directory ) : void
RemoveUserFromGroup ( System.DirectoryServices.AccountManagement.UserPrincipal user, System.DirectoryServices.AccountManagement.GroupPrincipal group ) : void
SMBserver ( string share, System.Boolean visversa ) : string[]
SetACL ( UserInformation userInfo, string ProfileExtension ) : System.Boolean
SyncUserPrincipalInfo ( UserInformation info ) : void

Method Details

GenerateRandomPassword() public static méthode

Generates a random password that meets most of the requriements of Windows Server when password policy complexity requirements are in effect. http://technet.microsoft.com/en-us/library/cc786468%28v=ws.10%29.aspx This generates a string with at least two of each of the following character classes: uppercase letters, lowercase letters, and digits. However, this method does not check for the existence of the username or display name within the generated password. The probability of that occurring is somewhat remote, but could happen. If that is a concern, this method could be called repeatedly until a string is returned that does not contain the username or display name.
public static GenerateRandomPassword ( int length ) : string
length int Password length, must be at least 6.
Résultat string

GetGroupPrincipal() public static méthode

public static GetGroupPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.GroupPrincipal
sid SecurityIdentifier
Résultat System.DirectoryServices.AccountManagement.GroupPrincipal

GetGroupPrincipal() public static méthode

Finds and returns the GroupPrincipal object if it exists, if not, returns null. This method uses PrincipalSearcher because it is faster than GroupPrincipal.FindByIdentity. The group name comparison is case insensitive.
public static GetGroupPrincipal ( string groupname ) : System.DirectoryServices.AccountManagement.GroupPrincipal
groupname string
Résultat System.DirectoryServices.AccountManagement.GroupPrincipal

GetUserDirectoryEntry() public static méthode

public static GetUserDirectoryEntry ( string username ) : System.DirectoryServices.DirectoryEntry
username string
Résultat System.DirectoryServices.DirectoryEntry

GetUserPrincipal() public static méthode

public static GetUserPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.UserPrincipal
sid SecurityIdentifier
Résultat System.DirectoryServices.AccountManagement.UserPrincipal

GetUserPrincipal() public static méthode

Finds and returns the UserPrincipal object if it exists, if not, returns null. This method uses PrincipalSearcher because it is faster than UserPrincipal.FindByIdentity. The username comparison is case insensitive.
public static GetUserPrincipal ( string username ) : System.DirectoryServices.AccountManagement.UserPrincipal
username string The username to search for.
Résultat System.DirectoryServices.AccountManagement.UserPrincipal

LocalAccount() public méthode

public LocalAccount ( UserInformation userInfo ) : System
userInfo pGina.Shared.Types.UserInformation
Résultat System

RemoveUserAndProfile() public méthode

public RemoveUserAndProfile ( string user, int sessionID ) : void
user string
sessionID int
Résultat void

ScrambleUsersPassword() public méthode

public ScrambleUsersPassword ( string username ) : void
username string
Résultat void

SyncLocalGroupsToUserInfo() public static méthode

public static SyncLocalGroupsToUserInfo ( UserInformation userInfo ) : void
userInfo pGina.Shared.Types.UserInformation
Résultat void

SyncToLocalUser() public méthode

public SyncToLocalUser ( ) : void
Résultat void

SyncUserInfoToLocalUser() public static méthode

public static SyncUserInfoToLocalUser ( UserInformation userInfo ) : void
userInfo pGina.Shared.Types.UserInformation
Résultat void

UserExists() public static méthode

This is a faster technique for determining whether or not a user exists on the local machine. UserPrincipal.FindByIdentity tends to be quite slow in general, so if you only need to know whether or not the account exists, this method is much faster.
public static UserExists ( string strUserName ) : bool
strUserName string The user name
Résultat bool