home *** CD-ROM | disk | FTP | other *** search
- #include "CreateUser.h"
- #include "MDUserImports.h"
-
-
- int main(int argc, char** argv)
- {
- int iLoadResult = 0;
- if (!LoadMDUserDll(iLoadResult, // buffer to store error result code
- NULL, // Optional path to the dll
- false)) // TRUE if you want the accounts loaded into memory after the dll has been initialized
- {
- cout << "Could not load the MDUserDll, error:" << iLoadResult << "\n";
- return -1;
- }
-
-
- if (CreateMDUser("Frank", "secret", "mydomain.com", "Frank Thomas"))
- cout << "User was created successfully\n";
- else
- cout << "Error creating user\n";
-
- // Release the MDUserDLL
- FreeMDUserDll();
-
- return 0;
- }
-
-
- bool CreateMDUser(string strMailbox, string strPassword, string strDomain, string strRealName)
- {
- MD_UserInfo UserInfo;
-
- // Copy new account defaults into structure
- MD_InitUserInfo(&UserInfo); // You must call MD_InitUserInfo on new UserInfo structures when creating users
-
- // copy data into UserInfo members
- strncpy(UserInfo.FullName, strRealName.c_str(), FULLNAME_LEN);
- strncpy(UserInfo.Domain, strDomain.c_str(), DOMAIN_LEN);
- strncpy(UserInfo.Mailbox, strMailbox.c_str(), MAILBOX_LEN);
- strncpy(UserInfo.Password, strPassword.c_str(), PASSWORD_LEN);
-
- MD_FilterUserInfo(&UserInfo);
-
- return (MD_AddUser(&UserInfo, 0) == MDDLLERR_NOERROR);
- }
-