CASA/c_sharp/NSSCSWrapper/miCASA.cs

134 lines
3.0 KiB
C#
Raw Normal View History

using System;
using Novell.CASA;
namespace Novell.CASA
{
/// <summary>
/// Summary description for miCASA.
/// </summary>
public class miCASA
{
public static uint USERNAME_TYPE_CN_F = 0x00000000;
public static uint USERNAME_TYPE_NDS_DN_F = 0x00000001;
public static uint USERNAME_TYPE_NDS_FDN_F = 0x00000002;
public static uint USERNAME_TYPE_LDAP_DN_F = 0x00000004;
public static uint USERNAME_TYPE_EMAIL_F = 0x00000008;
public static uint USERNAME_TYPE_OTHER_F = 0x00000010;
public miCASA()
{
//
// TODO: Add constructor logic here
//
}
public static void SetBasicCredential(
string sAppSecretID,
string sSharedSecretID,
string sUsername,
string sPassword)
{
SetCredential(0, sAppSecretID, sSharedSecretID, 0, sUsername, sPassword);
}
public static string GetCredentialUsername(
string sAppSecretID,
string sSharedSecretID)
{
BasicCredential bc = GetBasicCredential(sAppSecretID, sSharedSecretID);
if (bc != null)
return bc.GetUsername();
else
return null;
}
public static string GetCredentialPassword(
string sAppSecretID,
string sSharedSecretID)
{
BasicCredential bc = GetBasicCredential(sAppSecretID, sSharedSecretID);
if (bc != null)
return bc.GetPassword();
else
return null;
}
public static BasicCredential GetBasicCredential(
string sAppSecretID,
string sSharedSecretID)
{
return GetCredential(0, sAppSecretID, sSharedSecretID, miCASA.USERNAME_TYPE_CN_F);
}
public static void RemoveBasicCredential(
string sAppSecretID,
string sSharedSecretID)
{
RemoveCredential(0, sAppSecretID, sSharedSecretID);
}
public static void SetCredential(
uint ssFlags,
string sAppSecretID,
string sSharedSecretID,
uint unFlag,
string sUsername,
string sPassword)
{
NativeCalls.SetCredential(ssFlags, sAppSecretID, sSharedSecretID, unFlag, sUsername, sPassword);
}
public static BasicCredential GetCredential(
uint ssFlags,
string sAppSecretID,
string sSharedSecretID,
uint unFlag)
{
return NativeCalls.GetCredential(ssFlags, sAppSecretID, sSharedSecretID, unFlag);
}
public static void RemoveCredential(
uint ssFlags,
string sAppSecretID,
string sSharedSecretID)
{
NativeCalls.RemoveCredential(ssFlags, sAppSecretID, sSharedSecretID);
}
public static int SetMasterPassword(
uint ssFlags,
string mPasswd)
{
return NativeCalls.SetMasterPassword(ssFlags,mPasswd);
}
public static bool IsSecretPersistent(
uint ssFlags,
string secretID)
{
return NativeCalls.IsSecretPersistent(ssFlags,secretID);
}
2005-11-03 21:24:36 +01:00
public static bool ChangeMasterPassword(string sCurrentPassword, string sNewPassword)
{
if (sCurrentPassword == null || sNewPassword == null)
{
throw new miCasaException(miCasaException.NSSCS_E_INVALID_PARAM);
}
if (sNewPassword.Length < 8)
throw new miCasaException(miCasaException.NSSCS_E_MP_PWORD_NOT_ALLOWED);
return NativeCalls.ResetMasterPassword(sCurrentPassword, sNewPassword);
}
}
}