C# Class pGina.Plugin.LocalMachine.LocalAccount

Datei anzeigen Open project: MutonUfoAI/pgina Class Usage Examples

Public Methods

Method 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

Method 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 method

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.
return string

GetGroupPrincipal() public static method

public static GetGroupPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.GroupPrincipal
sid SecurityIdentifier
return System.DirectoryServices.AccountManagement.GroupPrincipal

GetGroupPrincipal() public static method

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
return System.DirectoryServices.AccountManagement.GroupPrincipal

GetUserDirectoryEntry() public static method

public static GetUserDirectoryEntry ( string username ) : System.DirectoryServices.DirectoryEntry
username string
return System.DirectoryServices.DirectoryEntry

GetUserPrincipal() public static method

public static GetUserPrincipal ( SecurityIdentifier sid ) : System.DirectoryServices.AccountManagement.UserPrincipal
sid SecurityIdentifier
return System.DirectoryServices.AccountManagement.UserPrincipal

GetUserPrincipal() public static method

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.
return System.DirectoryServices.AccountManagement.UserPrincipal

LocalAccount() public method

public LocalAccount ( UserInformation userInfo ) : System
userInfo pGina.Shared.Types.UserInformation
return System

RemoveUserAndProfile() public method

public RemoveUserAndProfile ( string user, int sessionID ) : void
user string
sessionID int
return void

ScrambleUsersPassword() public method

public ScrambleUsersPassword ( string username ) : void
username string
return void

SyncLocalGroupsToUserInfo() public static method

public static SyncLocalGroupsToUserInfo ( UserInformation userInfo ) : void
userInfo pGina.Shared.Types.UserInformation
return void

SyncToLocalUser() public method

public SyncToLocalUser ( ) : void
return void

SyncUserInfoToLocalUser() public static method

public static SyncUserInfoToLocalUser ( UserInformation userInfo ) : void
userInfo pGina.Shared.Types.UserInformation
return void

UserExists() public static method

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
return bool