Remove user from store Group

Jun 22, 2009 at 5:01 PM

Andrea,

How could I (in code) remove a user from a store group?

I know how to add them...but i don't see an easy way to remove them.

 

Thanks.
Craig

Jun 22, 2009 at 5:12 PM

Is this correct?

Dim azManDb As New NetSqlAzMan.SqlAzManStorage(dbConnectionString)

'Get the default or only store
Dim myStore As NetSqlAzMan.Interfaces.IAzManStore = azManDb.GetStore(Utils.AzManStoreName)

 'Get the correct storegroup to remove the user
 Dim imyStoregroup As IAzManStoreGroup = myStore.GetStoreGroup(storegroup.ToString())

 'Get my azmanID
 Dim myID As NetSqlAzMan.Interfaces.IAzManSid = GetUserSIDfromDB(user, dbConnectionString)

 Dim myMember As IAzManStoreGroupMember = imyStoregroup.GetStoreGroupMember(myID)
 myMember.Delete()

 

 

 

It's unclear to me if the "Delete" method is  the right one to call....thanks again.

Coordinator
Jun 22, 2009 at 5:27 PM

Exactly !

nice work.

__________________________________
Andrea Ferendeles
NetSqlAzMan - Project Coordinator

http://netsqlazman.codeplex.com

Jun 23, 2009 at 3:26 PM

Is there an easy way to remove a user from ALL their store groups? (Completely remove user from system)

My users could be in 1 up to 10 store group. I could:

1) iterate through all the store groups

2) check if member

3) Remove...

 

I'm just wondering if it could be easier.

 

Craig

Coordinator
Jun 23, 2009 at 5:47 PM

Hi cmacholtz,

using NetSqlAzMan.dll … yes .. it is the unique way.

If you want you can use a T-SQL statement like this:

BEGIN TRANSACTION

DELETE

FROM         netsqlazman_StoreGroupMembersTable

WHERE     (objectSid = SUSER_SID('MY DOMAIN\My user'))

DELETE

FROM         netsqlazman_ApplicationGroupMembersTable

WHERE     (objectSid = SUSER_SID('MY DOMAIN\My user'))

COMMIT TRANSACTION

__________________________________
Andrea Ferendeles
NetSqlAzMan - Project Coordinator

http://netsqlazman.codeplex.com