2006-01-19 00:34:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2006-01-31 23:01:47 +01:00
|
|
|
* Copyright (C) 2005-2006 Novell, Inc. Inc. All Rights Reserved.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2006-01-31 23:01:47 +01:00
|
|
|
* Library Lesser General Public License for more details.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-01-31 23:01:47 +01:00
|
|
|
* License along with this library; if not, Novell, Inc.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* To contact Novell about this file by physical or electronic mail,
|
|
|
|
* you may find current contact information at www.novell.com.
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
2006-01-31 23:01:47 +01:00
|
|
|
|
2005-10-11 21:51:00 +02:00
|
|
|
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);
|
|
|
|
}
|
2005-10-31 21:26:21 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
2005-10-11 21:51:00 +02:00
|
|
|
}
|
|
|
|
}
|